From the course: .NET Essentials: LINQ for Databases
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Find data within a date range - .NET Tutorial
From the course: .NET Essentials: LINQ for Databases
Find data within a date range
- [Instructor] I had a question from a student watching my link, Essential Training Course. Basically, the question was how to filter a query based on a date range. The twist of the question was how to do this based on the results of another query. So for this example, I'm querying the orders table, and I'm looking for this specific order. And when I get that order, I'm showing the OrderID, the OrderDate and the ShipName. So let's run this first query. There's my results. Now, what we want to do is find all the orders in our database that are within 30 days after this order. So the order data is 7/8/1996. I need to use that value and the other query to create the range. So what I'm doing is I'm defining a TimeSpan here on line three, for 30 days. Then I'm creating two dates; the start and end date. the originalDate is running this query and getting the OrderDate value. The futureDate is the originalDate + 30 days.…
Contents
-
-
-
-
-
-
-
(Locked)
Projection, get fewer columns2m 19s
-
(Locked)
Paging with Take and Skip1m 49s
-
(Locked)
Use Find for faster search by key1m 58s
-
(Locked)
Use EF navigation properties instead of joins3m 4s
-
(Locked)
Use the Contains method for1m 36s
-
(Locked)
Organize query results into groups with GroupBy3m 7s
-
(Locked)
Flatten child collections with SelectMany1m 36s
-
(Locked)
Find data within a date range1m 20s
-
(Locked)
-