DBSesson
public class DBSesson : IDBSesson
{
DbContext db = new book_shopEntities();
private IUserInfoDAL _userInfoDAL;
public IUserInfoDAL UserInfoDAL
{
get
{
if(_userInfoDAL==null)
{
_userInfoDAL = new UserInfoDAL();//抽象工厂
}
return _userInfoDAL;
}
set
{
_userInfoDAL = value;
}
}
//执行SQL语句
public int ExecuteSql(string sql, params System.Data.SqlClient.SqlParameter[] pars)
{
return db.Database.ExecuteSqlCommand(sql, pars);
}
public int SaveChanges()
{
return db.SaveChanges();
}
}