DAL设计

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LC.DAL
{
using IDAL;
using Entity;
public class VIPUsersDAL : IVIPUsers
{
public int Add(VIPUsers t)
{
using (EFDbContext dbContext = new EFDbContext())
{
dbContext.Entry(t).State = System.Data.Entity.EntityState.Added;
var result = dbContext.SaveChanges();
return result;
}
}

public int Delete(int Id)
{
using (EFDbContext dbContext = new EFDbContext())
{
var t = dbContext.VIPUsers.Find(Id);
dbContext.Entry(t).State = System.Data.Entity.EntityState.Deleted;
var result = dbContext.SaveChanges();
return result;
}
}

public List<VIPUsers> Query()
{
using (EFDbContext dbContext = new EFDbContext())
{
var result = dbContext.VIPUsers.ToList();
return result;
}
}

public VIPUsers QueryById(int Id)
{
using (EFDbContext dbContext = new EFDbContext())
{
var result = dbContext.VIPUsers.Find(Id);
return result;
}
}

public int Update(VIPUsers t)
{
using (EFDbContext dbContext = new EFDbContext())
{
dbContext.Entry(t).State = System.Data.Entity.EntityState.Modified;
var result = dbContext.SaveChanges();
return result;
}
}
}
}

posted @ 2018-11-22 18:23  嘻嘻哈哈嘿嘿呀  阅读(196)  评论(0编辑  收藏  举报