public static TObject GetModel <TObject>(TObject workingObject, EntitySelectQuery selectQuery) where TObject : class, IEntityObject, IEntityObject <TObject> { using (var context = new ModelsDbContext()) { context.Configuration.ProxyCreationEnabled = false; try { return(EntitySelectQuery.GetQueryable(workingObject, selectQuery, context).FirstOrDefault()); } catch (Exception ex) { throw new Exception("Failed To Get Object From Db", ex); } } }
public static EList <TObject> GetModels <TObject>(TObject workingObject, EntitySelectQuery selectQuery) where TObject : class, IEntityObject, IEntityObject <TObject> { using (var context = new ModelsDbContext()) { context.Configuration.ProxyCreationEnabled = false; try { var query = EntitySelectQuery.GetQueryable(workingObject, selectQuery, context); var eList = new EList <TObject>(); eList.AddRange(query.ToList()); return(eList); } catch (Exception ex) { throw new Exception("Failed To Get Object From Db", ex); } } }