I have a repository class, which as a method FromStore<TEntity>, as shown below:
IQueryable<TEntity> FromStore<TEntity>() where TEntity : class;
Using this, I can do things like:
MyRepository.FromStore<DatabaseModel>().SingleOrDefault(dm => dm.Id = Id);
Now I think it’s stupid to make class call users FromStorewhen I could provide the SingleOrDefault method directly (you just need to specify a parameter of the type type and not its output, as is usually the case).
So, I wrote a method as shown below:
public TEntity SingleOrDefault<TEntity>(Expression<Func<TEntity, bool>> filter) where TEntity : class
{
return FromStore<TEntity>().SingleOrDefault(filter);
}
Fine! Now I can do it:
MyRepository.SingleOrDefault<DatabaseModel>(dm => dm.Id = Id);
However, I want to do the same for all linq extension methods.
The only way I can do this now is to create similar wrapper methods for my class for each linq method.
It seems stupid, of course, the best way?
, - Repository , linq, IQueriable<T>. , T.
- linq , IQueryable<T> T?