标签:
对应的数据库帐号需要有创建存储过程的权限
以下查询会成成类似 ZautoSp_1E719B3EE5AFF6F4 的储储过程,删除后再查询时会自动生成
var query = Code.ProductDataManage.Instance.GetLamadaQuery(); //会按条件不同创建不同的存储过程 query = query.Where(b => b.Id < 700); string name = Request["name"]; if (!string.IsNullOrEmpty(name)) { query = query.Where(b => b.InterFaceUser == name); } var list = Code.ProductDataManage.Instance.QueryList(query, compileSp: true);
var helper = dbHelper; string sql = "select * from ProductData where datediff(d,addtime,@date)=0"; helper.AddParam("date", date); return helper.AutoSpQuery(sql);
var query = Code.ProductDataManage.Instance.GetLamadaQuery(); query = query.Where(b => b.SupplierId == "1"); int page = 1; int pageSize = 15; int count; query.Page(page, pageSize); //此查询会动态创建分页存储过程 var list = Code.ProductDataManage.Instance.AutoSpPage(query, out count);
//group分页测试 int page = 1; int pageSize = 15; int count; var helper = dbHelper; var query = "ProductData with (nolock) group by ProductId"; var fields = "ProductId,count(0) as total"; var rowOver = "count(0) desc"; var sort = "ProductId desc"; /// 对GROUP进行分页 /// /// /// 查询 如:ProductReceiptDetail with (nolock) group by styleid /// 查询字段 如:styleid,sum(num) as total /// 行排序 如:sum(num) desc /// 排序字段 如:total desc /// 每页大小 /// 页索引 /// /// return helper.AutoSpGroupPage(query, fields, rowOver, sort, pageSize, page, out count);
标签:
原文地址:http://www.cnblogs.com/hubro/p/4286329.html