Exemplo n.º 1
0
 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());
     }
 }
Exemplo n.º 2
0
 public List <T> LoadAllItems <T>() where T : class
 {
     using (var dbContext = new PEISEntities())
     {
         return(dbContext.Set <T>().ToList());
     }
 }
Exemplo n.º 3
0
 public T Load <T>(Expression <Func <T, bool> > whereLambda) where T : class
 {
     using (var dbContext = new PEISEntities())
     {
         return(dbContext.Set <T>().Where(whereLambda).FirstOrDefault());
     }
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 6
0
 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));
     }
 }
Exemplo n.º 7
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);
     }
 }