根据博客园“咖啡不苦不舒服”的文章“搭建一套自己实用的.net架构(3)【ORM-Dapper+DapperExtensions】”整合、杜撰的一套完整可运行代码。原地址:http://www.cnblogs.com/hy59005271/p/4759623.html。
去掉了HY.Web,添加了HY.Web.ConsoleTest控制台程序,做了如下测试:
var service = new DeployService();
//插入
service.Insert(entity);
//查询所有
var allList = service.GetAll();
//多条件查询
var pgMain = new PredicateGroup { Operator = GroupOperator.Or, Predicates = new List() };
var pga = new PredicateGroup() { Operator = GroupOperator.And, Predicates = new List() };
pga.Predicates.Add(Predicates.Field(f => f.DeployCode, Operator.Eq, "100"));
pga.Predicates.Add(Predicates.Field(f => f.ID, Operator.Ge, 47));
pga.Predicates.Add(Predicates.Field(f => f.ID, Operator.Le, 48));
pgMain.Predicates.Add(pga);
var pgb = new PredicateGroup() { Operator = GroupOperator.And, Predicates = new List() };
pgb.Predicates.Add(Predicates.Field(f => f.DeployCode, Operator.Eq, "10000"));
pgMain.Predicates.Add(pgb);
var specialList = service.GetList(pgMain).ToList();
//分页查询
long allRowsCount = 0;
var pageList = service.GetPageList(1, 2, out allRowsCount);
2021-07-30 20:31:00
128KB
HY.
1