score:3
Accepted answer
try this:
func<myobject, bool> datepredicate = (o => o.date > datetime.now.adddays(-1));
collection.where(datepredicate);
also when you're doing .singleordefault()
, not sure how that will magically turn into a type
since your list<t>
is not a list<type>
as far as i know (since type
doesn't have a date
property).
score:0
the compiler cannot statically figure out what type
your o
parameter is. i would presume o
is of type datetime
. compilers don't make presumptions :)
predicate<datetime> datepredicate = o => o.date > datetime.now.adddays(-1);
try that.
Source: stackoverflow.com
Related Query
- C# error when using explicitly defined Predicate
- Error when using XDocument in code behind
- Entity-framework code is slow when using Include() many times
- Why does this error occur when using SingleAsync?
- Is order of the predicate important when using LINQ?
- Reference required error only when using LINQ
- Entity Framework Linq Query to List - Error when using contains: Only primitive types, enumeration types and entity types are supported
- How to reuse a linq expression for 'Where' when using multiple source tables
- Avoiding code repetition when using LINQ
- Why do I get a "key already added" error when using the key from a GroupBy in ToDictionary?
- Linq to entity framework error when using datetimeoffset
- Compiler error when using LINQ on IEnumerable<dynamic> but not if you cast it to IEnumerable<dynamic> first
- SQLite error when accessing first element in table using LINQ
- Error When Querying For A Substring Using Dynamic Linq
- Error when defining a query param type List<int> inline using Linq
- Error when using "Include" method on a LINQ Query
- LINQ Error When using DefaultIfEmpty
- Linq sub query when using a repository pattern with EF code first
- Are we compromising performance for achieving code readability when using LINQ?
- Error when using a Linq Expression variable instead of lambda expression directly
- Using a Repository getting error No parameterless constructor defined for this object
- Error when using WCF dataservice
- using where clause inside include generate error "The Include path expression must refer to a navigation property defined on the type"
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- Error when redefining a different xml Namespace to an existing alias using XElement with System.Xml.Linq
- Getting DataTable column names using linq, error when column is null
- Error in linq query when using average
- Entity Framework Core Not Generating Where Clause When Using LINQ and predicate
- Error when using index inside a .Select in a LINQ QUery:
- Compiling Error with LINQ Sorting Code Using List<T>
More Query from same tag
- c# if else then statement with LINQ
- How to implement SkipWhile with Linq to Sql without first loading the whole list into memory?
- Problem using linq to concat two collections
- Need help to validate existing group of records
- If I'm projecting with linq and not using a range variable what is the proper syntax?
- Linq OrderBy does not sort a List<T>. How do I sort the list?
- Select strokes from inkcanvas within a rectangle by program
- Getting error in linq to entity
- return different linq to sql result sets into single object(json format)?
- Cannot compare elements of type 'System.Collections.Generic.ICollection`1 Only primitive types, enumeration types and entity types are supported
- Parse Table presented in WebControl
- Linq to Entities eqiuvalent to a filtered inline view in T-SQL
- Differences in LINQ syntax between VB.Net and C#
- Co-related Queries using lambda expressions
- Grouping based on the order of data
- LINQ - Select Specific Columns
- Adding additional information to a list from a linq-to-entities query
- Do multiple DbContext generate a deadlock?
- Best way to find values not in two lists c#
- How do I get the latest date from a collection of objects using LINQ?
- Generate sequence with step value
- How do I write EF.Functions extension method?
- LINQ to SQL Storing query results in a variable
- Translate a LINQ query to LINQJS
- parsing an xmldocument from a webrequest
- How can I use external method in LINQ OrderBy
- Linq value between 2 column ranges
- Best way to map a parent-child list of objects
- C# LINQ merging list and dictionary into new dictionary
- How to sum elements of unknown number of arrays using LINQ?