score:2
Accepted answer
you have to filter between a start and end date if you want to make use of whatever indexes you might have on depositdate
. if you do not care about that there are canonical date functions you can use to strip the time from the database value.
datetime today = datetime.today;
datetime tomorrow = today.adddays(1);
var deposit = (from u in db.deposit
where u.depositdate >= today && u.depositdate < tomorrow
select u).tolist();
or as a lambda
var deposits = db.deposit
.where(u => u.depositdate >= today && u.depositdate < tomorrow)
.tolist();
as a side note and also a matter of opinion it generally recommended to pluralize dbset<t>
properties on your dbcontext
(like db.deposits
). the same goes for your variable deposit
as it will be of type list<deposit>
which is a collection (the 2nd code sample i changed it).
Source: stackoverflow.com
Related Query
- How works datetime and How to compare two dates in windows form ADO Entities?
- how to combine two columns Date and Time and compare it with given DateTime using linq
- How to compare only Date portion in DateTime in LINQ to Entities (Case:- Dates are equal)
- How can I compare two unordered sequences (list and array) for equality?
- How can I compare two sets of data in linq and return the common data?
- How to compare two lists on a combination of two properties and select a row which has mismatch in the third property?
- How can I compare two Lists and create another list where the match?
- C# Linq how to compare two strings and report the first different char which is itself different from '?' wildcard
- How to compare two string arrays and store the matching values in another string array?
- How to compare two lists with multiple objects and set values?
- How do I compare two lists where one list starts with the other, and only return the "overhang" elements?
- How to compare two lists and change one property
- How can I do a LINQ query joining two entities and select what a Where on one of the entities?
- How to compare two lists and set value to list property
- How can i compare and seach string and datetime c#
- How can I use and compare string datetime in c# linq to sql?
- How to compare two list and get the differences from first list?
- C# LINQ code for two list compare and replace
- How can I subtract two dates and get a new date converted in minutes?
- how to compare values between two collections and only render distinct values within a listbox using asp.net
- How to compare two List content data and return mismatch value?
- Using LINQ. How can I compare two simple lists to give another list of objects in the new and not in the old list?
- How to compare two lists and find the mismatch them in c#?
- How to know if a DateTime is Between two Dates in Entity Framework Core
- How to compare two list values and round them to first list values without adding them internally
- How to compare two datatables and only check for the rows found
- how to compare two list and subtract single column value in c#
- How to Join two Entities and Get Unique Rows from One
- How to compare the dates and gets the day count using c# in LINQ
- Subtract Two datetime (TimeStamp) and compare with interval in hours (int) in lambda query
More Query from same tag
- Using LINQ, select first of each group, create new obj with specific columns
- feature an item based on the date
- Linq Query Failed to Merge Two Tables Record
- Read all XML child nodes of each specific node
- Accessing Linq data in telerik grid ItemCreated method
- Simplify LINQ query
- dynamic sort in linq
- How to fix that internal query
- How to group LINQ query to dictionary<string, string>
- Navigation Properties not returning when included using a loop
- how to generate next ID from database
- VB.NET LINQ to DataSet (SQL 'LEFT OUTER JOIN' alternative)
- I want to apply Except between two lists. One list is in MailAddress format and other is a String (Converted to list))
- I've just upgraded from a VS2010 project, but my linq query now won't sum an anonymous type
- removing column and rows from DataTable using Linq
- Compile a list of unique objects using LINQ
- Optimize finding all classes implementing IInterface<T> and those explicitly implementing it with a specific type
- Orchard get content by taxonomy
- Linq | Iterative Groupby on a List<>
- Cannot implement type XYZ with a collection initializer because it does not implement 'System.Collections.IEnumerable'
- Select XML element without using Extension method
- Linq Performance: (ElementAt,Count) vs (foreach)
- Linq UNION query to select two elements
- Remove Items from Embedded List<object> using LINQ
- Entity Framework - Group and Min
- Good way to connect parent table/entity with child table/entities?
- linq 'group by' selecting a number of entities that match a max criteria
- IQueryable<T> Extension Method not working
- LinqPad Feature - Does VS do this?
- Build Linq query in umbraco