How to use the LINQ where expression?

Posted by NullReference on Stack Overflow See other posts from Stack Overflow or by NullReference
Published on 2011-11-29T17:29:36Z Indexed on 2011/11/29 17:49 UTC
Read the original article Hit count: 296

I'm implementing the service \ repository pattern in a new project. I've got a base interface that looks like this. Everything works great until I need to use the GetMany method. I'm just not sure how to pass a LINQ expression into the GetMany method. For example how would I simply sort a list of objects of type name?

nameRepository.GetMany( ? )

public interface IRepository<T> where T : class
{
    void Add(T entity);
    void Update(T entity);
    void Delete(T entity);
    void Delete(Expression<Func<T, bool>> where);
    T GetById(long Id);
    T GetById(string Id);
    T Get(Expression<Func<T, bool>> where);
    IEnumerable<T> GetAll();
    IEnumerable<T> GetMany(Expression<Func<T, bool>> where);

}



 public virtual IEnumerable<T> GetMany(Expression<Func<T, bool>> where)
 {
    return dbset.Where(where).ToList();
 }

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about entity-framework