Exemplo n.º 1
0
 public T GetById(int id)
 {
     using (DbDataContextDataContext objDataContext = new DbDataContextDataContext())
     {
         var table = objDataContext.GetTable <T>();
         return(table.Where <T>(obj => obj.id == id).DefaultIfEmpty().Single());
     }
 }
Exemplo n.º 2
0
 public ICollection <T> GetListAll()
 {
     using (DbDataContextDataContext objDataContext = new DbDataContextDataContext())
     {
         var table = objDataContext.GetTable <T>();
         return(table.Where <T>(obj => true).ToList());
     }
 }
Exemplo n.º 3
0
 public override void Update(ModelCar obj)
 {
     using (DbDataContextDataContext objDataContext = new DbDataContextDataContext())
     {
         var mc = objDataContext.model_cars.Single(element => element.id == obj.id);
         mc.model = obj.model;
         objDataContext.SubmitChanges();
     }
 }
Exemplo n.º 4
0
 public override void DeleteById(int id)
 {
     using (DbDataContextDataContext objDataContext = new DbDataContextDataContext())
     {
         var obj = objDataContext.model_cars.Single(element => element.id == id);
         objDataContext.model_cars.DeleteOnSubmit(obj);
         objDataContext.SubmitChanges();
     }
 }
Exemplo n.º 5
0
 public override void Create(ModelCar obj)
 {
     using (DbDataContextDataContext objDataContext = new DbDataContextDataContext())
     {
         var table = objDataContext.GetTable <ModelCar>();
         table.InsertOnSubmit(obj);
         objDataContext.SubmitChanges();
     }
 }
Exemplo n.º 6
0
 public override void Update(Color obj)
 {
     using (DbDataContextDataContext objDataContext = new DbDataContextDataContext())
     {
         var c = objDataContext.colors.Single(element => element.id == obj.id);
         c.color1 = obj.color;
         objDataContext.SubmitChanges();
     }
 }
Exemplo n.º 7
0
 public override void Update(GosNumber obj)
 {
     using (DbDataContextDataContext objDataContext = new DbDataContextDataContext())
     {
         var gn = objDataContext.gos_numbers.Single(element => element.id == obj.id);
         gn.number     = obj.number;
         gn.region     = obj.region;
         gn.serial     = obj.serial;
         gn.idColor    = obj.idColor;
         gn.idModelCar = obj.idModelCar;
         objDataContext.SubmitChanges();
     }
 }