标签:get str manager query st3 条件查询 bsp val ati
var connStr = ConfigurationManager.ConnectionStrings["dbconnstr"].ConnectionString;
SQLContext db = new SQLContext(connStr);
//list查询
var list1 = db.GetList<Config>(s => s.ID > 5);
var list2 = db.GetList<Config>("select * from BAS_Config where id > @id", null, new SqlParameter("@id", 5));
var list3 = db.Query<Config>().Where(s => s.ID > 5).ToList();
//多条件查询
var query = db.Query<Config>();
query.Where(s => s.ParamType == "b");
query.Where(s => s.ID > 5);
var result = query.ToList();
//分页查询
var pageResult1 = db.GetPageResult<Config>(new SQL.PageHelper.PageBase { PageIndex = 0, PageSize = 10 }, s => s.ID, true);
var pageResult2 = db.GetPageResult<Config>(new SQL.PageHelper.PageBase { PageIndex = 0, PageSize = 10 }, "select * from BAS_Config", "Id asc");
var pageResult3 = db.Query<Config>().ToPageResult(new SQL.PageHelper.PageBase { PageIndex = 0, PageSize = 10 }, s => s.ID, true);
//插入
int row1 = db.Insert<Config>(new Config { ParamID = "a", ParamType = "a", ParamValue = "a" }, false);
int row2 = db.InsertBatch<Config>(new List<Config> {
new Config { ParamID = "b", ParamType = "b", ParamValue = "b" },
new Config { ParamID = "c", ParamType = "c", ParamValue = "c" }
});
//更新
int update1 = db.Update<Config>(new Config { ID = 10033, ParamID = "aaa", ParamType = "aaa", ParamValue = "aaa", Remark = "aa" });
int update2 = db.Query<Config>().Set(s => s.ParamID, "aaa").Set(s => s.ParamType, "aaa").Where(s => s.ID == 10033).Update();
//删除
int delete1 = db.Delete<Config>(s => s.ID == 10033);
int delete2 = db.Query<Config>().Where(s => s.ID == 10033).Delete();
标签:get str manager query st3 条件查询 bsp val ati
原文地址:http://www.cnblogs.com/wuyifeixiang/p/6970781.html