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();