Database Reference
In-Depth Information
Figure 11-9. The MovieRental entity that has the dates for a rental period along with any late fees
You want to retrieve all of the movies that were returned more than 10 days after they were rented. These are the
late movies.
To create and use this query, follow the pattern shown inListing 11-16.
Listing 11-16. Retrieving the Late Movies using the DateDiff() Function
class Program
{
static void Main(string[] args)
{
RunExample();
}
static void RunExample()
{
using (var context = new EFRecipesEntities())
{
var mr1 = new MovieRental
{
Title = "A Day in the Life",
RentalDate = DateTime.Parse("2/19/2013"),
ReturnedDate = DateTime.Parse("3/4/2013"),
LateFees = 3M
};
var mr2 = new MovieRental
{
Title = "The Shortest Yard",
RentalDate = DateTime.Parse("3/15/2013"),
ReturnedDate = DateTime.Parse("3/20/2013"),
LateFees = 0M
};
var mr3 = new MovieRental
{
Title = "Jim's Story",
RentalDate = DateTime.Parse("3/2/2013"),
ReturnedDate = DateTime.Parse("3/19/2013"),
LateFees = 3M
};
 
Search WWH ::




Custom Search