示例#1
0
 /// <summary>
 /// Gets a list of entities of the given type from the database.
 /// </summary>
 /// <param name="orderBy">The order by expression to run at the database level. It supports only one property.</param>
 /// <param name="desc">Specified whether the order by is descending.</param>
 public static IEnumerable <T> GetList <T>(Expression <Func <T, bool> > criteria, Expression <Func <T, object> > orderBy, bool desc = false) where T : IEntity
 {
     return(GetList <T>(criteria, QueryOption.OrderBy <T>(orderBy, desc)));
 }
 /// <summary>
 /// Find an object with the specified type from the database.
 /// When used with no criteria, returns the first object found of the specified type.
 /// If not found, it returns null.
 /// </summary>
 /// <param name="orderBy">The order by expression to run at the database level. It supports only one property.</param>
 /// <param name="desc">Specified whether the order by is descending.</param>
 public static T Find <T>(Expression <Func <T, bool> > criteria, Expression <Func <T, object> > orderBy, bool desc = false) where T : IEntity
 {
     return(GetList <T>(criteria, QueryOption.OrderBy <T>(orderBy, desc), QueryOption.Take(1)).FirstOrDefault());
 }