DAL层

private DbContext MyContext;
        public BaseRepository(DbContext context)
        {
            MyContext = context;
        }

public IQueryable<S> GetAllGroups<S>(Expression<Func<T, bool>> predicate, Expression<Func<T, S>> selectLambda)
        {
            var query = MyContext.Set<T>().Where(predicate).AsQueryable();

            return query.Select(selectLambda);
        }

运用

List<Guid> lstguid=cis.GetAllGroups<Guid>(a => a.GroupID != null, a => a.GroupID).ToList();

 

posted on 2015-11-05 17:09  慕凡尘  阅读(139)  评论(0编辑  收藏  举报