1.项目中经常要用到 EF,有时候大多数的增删改查都是重复性的东西,本次封装就是为了快速开发,期间没有考虑到架构上的各种思想,就感觉到欠缺点什么东西所以这次将这些拉出来,有存在问题的话还请各位多多指导。例如这样调用:Account currAccount = new DataBL ...
1.项目中经常要用到 EF,有时候大多数的增删改查都是重复性的东西,本次封装就是为了快速开发,期间没有考虑到架构上的各种思想,就感觉到欠缺点什么东西所以这次将这些拉出来,有存在问题的话还请各位多多指导。例如这样调用:
Account currAccount = new DataBLL<Account>(ConfigHelper.Constr_read).Get(p => p.UserId == 1111);//查询一个账户
Account currAccount = new DataBLL<Account>(ConfigHelper.Constr_write).AddEntity(“一个实体”);//新增
Account currAccount = new DataBLL<Account>(ConfigHelper.Constr_write).DeleteAll(p=>p.Sex=1);//删除所有
Account currAccount = new DataBLL<Account>(ConfigHelper.Constr_write).DeleteAll(List<实体> tList);//删除所有 a.2: DALContext.cs 代码如下:
namespace Test.Web.Site.DAL{ public class DALContext<T> : DbContext where T : class { public DALContext(get='_blank'>string con) : base(con){} public DALContext(){} public DbSet<T> TV { get; set; } }}
原标题:MVC,EF 小小封装
关键词:mvc
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。