public List <T> LoadAll <T>(Expression <Func <T, bool> > whereLambda) where T : class { using (var dbContext = new PEISEntities()) { return(dbContext.Set <T>().Where(whereLambda).ToList()); } }
public List <T> LoadAllItems <T>() where T : class { using (var dbContext = new PEISEntities()) { return(dbContext.Set <T>().ToList()); } }
public T Load <T>(Expression <Func <T, bool> > whereLambda) where T : class { using (var dbContext = new PEISEntities()) { return(dbContext.Set <T>().Where(whereLambda).FirstOrDefault()); } }
public bool Insert <T>(T t) where T : class { using (var dbContext = new PEISEntities()) { dbContext.Set <T>().Add(t); if (dbContext.SaveChanges() != 0) { return(true); } } return(false); }
public bool Remove <T>(T t) where T : class { using (var dbContext = new PEISEntities()) { dbContext.Entry(t).State = System.Data.Entity.EntityState.Deleted; if (dbContext.SaveChanges() != 0) { return(true); } } return(false); }
public IEnumerable <long> GetCustIdByName(string custName) { using (var dbContext = new PEISEntities()) { var target = (from m in dbContext.OnCustRelationCustPEInfo join c in dbContext.OnArcCust on m.IDCardNo equals c.IDCard where c.CustomerName.Contains(custName) select m); return(target?.Select(p => p.ID_Customer ?? 0)); } }
public long GetCustIdByArcId(string idCardNumber) { using (var dbContext = new PEISEntities()) { var target = (from m in dbContext.OnCustRelationCustPEInfo join c in dbContext.OnArcCust on m.IDCardNo equals c.IDCard where m.IDCardNo == idCardNumber select m); return(target?.FirstOrDefault()?.ID_Customer ?? 0); } }