Szq. orm. SQL detailed instructions, szq. orm. SQL
Var connStr = ConfigurationManager. ConnectionStrings ["dbconnstr"]. ConnectionString;
SQLContext db = new SQLContext (connStr );
// List Query
Var list1 = db. GetList <Config> (s => s. ID> 5 );
Var list2 = db. GetList <Config> ("select * from Config where id> @ id", null, new SqlParameter ("@ id", 5 ));
Var list3 = db. Query <Config> (). Where (s => s. ID> 5). ToList ();
// Multi-condition Query
Var query = db. Query <Config> ();
Query. Where (s => s. Name = "B ");
Query. Where (s => s. ID> 5 );
Var result = query. ToList ();
// Query by PAGE
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 Config", "Id asc ");
Var pageResult3 = db. Query <Config> (). ToPageResult (new SQL. PageHelper. PageBase {PageIndex = 0, PageSize = 10}, s => s. ID, true );
// Insert
Int row1 = db. Insert <Config> (new Config {Name = ""});
Int row2 = db. InsertBatch <Config> (new List <Config> {
New Config {Name = "B "},
New Config {Name = "c "}
});
// Update
Int update1 = db. Update <Config> (new Config {ID = 10033, Name = "aa "});
Int update2 = db. query <Config> (). set (s => s. name, "aaa "). where (s => s. ID = 10033 ). update ();
// Delete
Int delete1 = db. Delete <Config> (s => s. ID = 10033 );
Int delete2 = db. Query <Config> (). Where (s => s. ID = 10033). Delete ();
Int delete3 = db. Delete <Config> (new Config {ID = 10035 });
// If the preceding statements are not supported, download the latest version.
: Http://files.cnblogs.com/files/wuyifeixiang/orm.rar