Szq.orm.sql detailed instructions for use

Source: Internet
Author: User

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 Bas_config where ID > @id", NULL, New SqlParameter ("@id", 5));
var list3 = db. Query<config> (). Where (s = = s.id > 5). ToList ();


Multi-Criteria Query
var query = db. Query<config> ();
Query. Where (s = = S.paramtype = = "B");
Query. Where (s = = s.id > 5);
var result = query. ToList ();


Paging Query
var PAGERESULT1 = db. Getpageresult<config> (New SQL. pagehelper.pagebase {PageIndex = 0, PageSize = ten}, s = = S.id, true);
var pageResult2 = db. Getpageresult<config> (New SQL. pagehelper.pagebase {PageIndex = 0, PageSize = ten}, "select * from Bas_config", "Id ASC");
var PAGERESULT3 = db. Query<config> (). Topageresult (New SQL. pagehelper.pagebase {PageIndex = 0, PageSize = ten}, s = = S.id, true);


Insert
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"}
});


Update
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 ();


Delete
int delete1 = db. Delete<config> (s = = S.id = = 10033);
int delete2 = db. Query<config> (). Where (s = = S.id = 10033). Delete ();

Szq.orm.sql detailed instructions for use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.