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()); } }
public ICollection <T> GetListAll() { using (DbDataContextDataContext objDataContext = new DbDataContextDataContext()) { var table = objDataContext.GetTable <T>(); return(table.Where <T>(obj => true).ToList()); } }
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(); } }
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(); } }
public override void Create(ModelCar obj) { using (DbDataContextDataContext objDataContext = new DbDataContextDataContext()) { var table = objDataContext.GetTable <ModelCar>(); table.InsertOnSubmit(obj); objDataContext.SubmitChanges(); } }
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(); } }
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(); } }