public List <TEntity> GetList(Expression <Func <TEntity, bool> > filter = null, List <string> includes = null) { try { using (var context = new TIOREMEntities()) { IQueryable <TEntity> query = context.Set <TEntity>(); if (includes != null) { foreach (var include in includes) { query = query.Include(include); } } if (filter == null) { return(query.ToList()); } else { return(query.Where(filter).ToList()); } } } catch (Exception ex) { throw new ArgumentException(filter.ToString(), aymkMethodType.GetList, ex); } }
public TEntity Get(Expression <Func <TEntity, bool> > filter = null, List <string> includes = null, bool isNullControl = false) { try { using (var context = new TIOREMEntities()) { IQueryable <TEntity> query = context.Set <TEntity>(); if (includes != null) { foreach (var include in includes) { query = query.Include(include); } } var data = query.SingleOrDefault(filter); if (isNullControl) { if (data == null) { throw new ArgumentException(filter.ToString(), aymkMethodType.NotFound); } else { return(data); } } else { return(data); } } } catch (Exception ex) { throw new ArgumentException(filter.ToString(), aymkMethodType.Get, ex); } }