Beispiel #1
0
        /// <summary>
        /// Return all entities from db collection
        /// </summary>
        /// <returns></returns>
        public virtual List <T> GetAll(Expression <Func <T, object> > @select = null, QueryOptions queryOptions = null)
        {
            var query = new SQLinq <T>();

            if (select != null)
            {
                query = query.Select(@select);
            }
            return(Using(connection =>
            {
                var data = connection.Query(query.ApplyQueryOptions(queryOptions));
                return data.ToList();
            }));
        }
Beispiel #2
0
 /// <summary>
 /// Return an entity that match the criteria
 /// </summary>
 /// <param name="select"></param>
 /// <param name="predicate"></param>
 /// <returns></returns>
 public virtual T FirstOrDefault(Expression <Func <T, object> > @select, Expression <Func <T, bool> > predicate)
 {
     return(Using(connection =>
     {
         var query = new SQLinq <T>();
         if (select != null)
         {
             query = query.Select(@select);
         }
         if (predicate != null)
         {
             query = query.Where(predicate);
         }
         var result = connection.Query(query).FirstOrDefault();
         return result;
     }));
 }