score:0
if it's nullable you need to use the value
property first, then call date
on that:
p.create_dt.value.date
that said, using the date
property will return the date with a timestamp of midnight, so it will still have a time associated with it. that won't be helpful for what you're describing. you can use @albertein's suggestion and check for the range.
score:0
if create_dt is allowed to have the null value in the database it will be mapped to a date?
type in .net (that is the generic type nullable<data>
).
you can retrieve the actual date of a nullable type by its value property.
try
from p in gl_projects
where p.create_dt.value.date == new datetime(2009,10,26)
select new p
but this will throw an exception if a create_dt is really null. to avoid this exception you have to ensure that the nullable type really contains a value:
from p in gl_projects
where p.create_dt.hasvalue && p.create_dt.value.date == new datetime(2009,10,26)
select new p
score:2
just check for the range
from p in gl_projects
where p.create_dt >= new datetime(2009,10,26) &&
p.create_dt < new datetime(2009,10,27)
select new p
Source: stackoverflow.com
Related Query
- LinqToSql with dates problem
- Linq to sql as object data source - designer problem with partial classes
- Problem with LINQ to Entities and String.StartsWith
- What does this C# code with an "arrow" mean and how is it called?
- Problem with linq query
- Problem with LINQ - necessary to add reference to unneeded library
- Why doesn't this code compile in VS2010 with .NET 4.0?
- Problem with LINQ to Entities query using Sum on child object property
- Problem with inheritance and List<>
- Problem With LINQ Model - Can't Assign NULL To Nullable Boolean!
- Temporary tables in Linq -- Anyone see a problem with this?
- Why is this code with PredicateBuilder not working?
- Can you advise me a resource with LINQ/lambda code exercises?
- Extending LINQ to Nhibernate provider, in combination with Dynamic LINQ problem
- LINQ Source Code Available
- Learn LinqToSql or stick with ADO.NET?
- Problem with Generic Linq OrderBy function
- Linq with where clause in many-to-many EF Code First object
- How to solve the greatest-n-per-group problem with Entity Framework (Core)?
- C# Code Contracts -- How to ensure that a collection of items contains items with unique properties?
- .NET 4 Code Contracts: "requires unproven: source != null"
- Problem with adding record using LINQ to SQL
- C#: Adding Columns To Bound DatagridView With Code
- Exploding a range of dates with LINQ
- Problem with Mapping/Casting Linq-to-Sql on different Types
- Problem getting data with LINQ in C# from localdb
- Query expressions over source type 'dynamic' or with a join sequence of type 'dynamic' are not allowed
- OrderBy Linq with US Dates
- linq to sql Association problem with foreign keys
- Problem with order by in LINQ
More Query from same tag
- linq where clause causes exception
- Searching for certain mail addresses: The Method "Contains" is not supported
- How can I use linq to return integers in one array that do not match up with an integer property of another array?
- LINQ Enumerable Threading
- How to tell LINQ providers about version/type of SQL Server before hand?
- How can i call from another method a linq?
- Null reference in lambda max count
- Linq to entities and Expression
- how to write code to find element in directory in Linq
- How do I check composite ID exists?
- List<T> to implement IQueryable<T>
- Cast function expression tree from object
- DBNull exception in query expression
- Simple search of XDocument
- Add " | " in string if where string value is not null or empty
- vb.net LINQ to Object grouping by create date
- How to specify strongly typed navigational property includes
- Using Max in LINQ query - null values in the list
- IQueryable does not contain definition for GetAwaiter
- How do I use Linq to select the top/bottom N contestants in a Ranked Choice Vote?
- How to group by date time in c# for a specific range?
- How to get a count of every single element in an xml file using linq to xml?
- What does the error "Extension method must be static" mean?
- How to get a running total of a decimal in a query?
- DbExpressionBinding requires an input expression with a collection ResultType. Parameter name: input
- Linq grouping and max value
- Select records which has no day-off throughout the week in List<T> - C#
- c# Linq Chain with avoid null exeption
- How to query using linq statements?
- Combine two LINQ queries?