Example #1
0
 /// <summary>
 /// 通过Lambda作为参数传递,返回集合
 /// </summary>
 /// <typeparam name="T">实体模型</typeparam>
 /// <param name="wherestr">Lambda作为参数</param>
 /// <returns></returns>
 public static List <T> GetListTowhereExp <T>(Expression <Func <T, bool> > wherestr) where T : class, new()
 {
     using (MyDbContexts db = new MyDbContexts())
     {
         return(db.Set <T>().Where(wherestr).ToList());
     }
 }
Example #2
0
 /// <summary>
 /// 通过Lambda作为参数传递,返回查询出的模型数据
 /// </summary>
 /// <typeparam name="T">实体模型</typeparam>
 /// <param name="wherestr">Lambda作为参数</param>
 /// <returns></returns>
 public static T GetModelTowhereExp <T>(Expression <Func <T, bool> > wherestr) where T : class, new()
 {
     using (MyDbContexts db = new MyDbContexts())
     {
         return(db.Set <T>().Where(wherestr).FirstOrDefault());
     }
 }