I'm trying to do a Query in Entity Framework using Repository pattern like this:
Namespace: Services
List<Data.Item> itemToday = repositoryUser.Get(i => i.UserId.Equals(user.Id) &&
i.Created.Date < DateTime.Now.Date)
.ToList();
Namespace: Data (my repository)
public IEnumerable<T> Get(System.Linq.Expressions.Expression<Func<T, bool>> expressionFilter)
{
return this.dbContext.Set<T>().Where(expressionFilter);
}
This will throw this error:
The specified type member 'Date' is not supported in LINQ to Entities
I found these questions to solve this with an Entity Framework method to convert date types and compare
But these solutions use a EF method that's stored in Data namespace, and I'm querying at Service namespace and I shouldn't call a repository function in Service layer, right? So how can I do this?