.net 泛型运用

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();
上一篇:ArrayList相关问题


下一篇:[ javascript canvas 插件演示 ] canvas 插件演示