Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AccountTypeDao : IAccountTypeDao
- {
- public void Delete(long id)
- {
- var context = new AutoServiceShopContext();
- var user = context.AccountTypees.Where(x => x.Id == id).First();
- context.AccountTypees.Remove(user);
- context.SaveChanges();
- }
- public void Delete(Data.Entity.AccountType entity)
- {
- var context = new AutoServiceShopContext();
- context.AccountTypees.Remove(entity);
- context.SaveChanges();
- }
- public void Delete(List<long> idList)
- {
- idList.ForEach(x => Delete(x));
- }
- public List<Data.Entity.AccountType> Find()
- {
- var context = new AutoServiceShopContext();
- return context.AccountTypees.ToList();
- }
- public Data.Entity.AccountType Find(long id)
- {
- var context = new AutoServiceShopContext();
- return context.AccountTypees
- .Where(x => x.Id.Equals(id))
- .Single();
- }
- public List<Data.Entity.AccountType> FindByField(string field, string value)
- {
- var context = new AutoServiceShopContext();
- return context.AccountTypees.Where
- (entity => entity.GetType().GetProperty(field).GetValue(entity, null).ToString().Equals(value)).ToList();
- }
- public Data.Entity.AccountType Save(Data.Entity.AccountType entity)
- {
- var context = new AutoServiceShopContext();
- context.AccountTypees.Add(entity);
- context.SaveChanges();
- return entity;
- }
- public List<Data.Entity.AccountType> Save(List<Data.Entity.AccountType> entity)
- {
- var context = new AutoServiceShopContext();
- entity.ForEach(x => context.AccountTypees.Add(x));
- context.SaveChanges();
- return entity;
- }
- public Data.Entity.AccountType Update(Data.Entity.AccountType entity)
- {
- Delete(entity.Id);
- Save(entity);
- return entity;
- }
- public List<Data.Entity.AccountType> Update(List<Data.Entity.AccountType> entity)
- {
- entity.ForEach(x => Update(x));
- return entity;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement