A high-performance, easy-to-use, cross-database access framework 3 (advanced features of Qin. Data)

Source: Internet
Author: User
1) query.

Query entities

DBTool db = new DBTool (Table. EventBaseSet); // specifies the Table
Db. Where = EventBaseSet. EventID _. Equals _ (3); // lock the record
Var data = db. GetEntity <EventBaseSet> (); // retrieves an object

 

Query specified fields

DBTool db = new DBTool (Table. EventBaseSet );
Db. Where = EventBaseSet. EventID _. Equals _ (32 );

Var name = db. GetOneField <string> (EventBaseSet. EventID _);

 

Multi-field Query
DBTool db = new DBTool (Table. EventBaseSet );
Db. Where = EventBaseSet. EventID _. Equals _ (32 );
Var row = db. GetDestinationFields (EventBaseSet. EnabledBodyHtml _, EventBaseSet. Days _);

Compound condition Query

DBTool db = new DBTool (Table. EventBaseSet );
Db. Where = EventBaseSet. EventID _. BiggerThan _ (32). And _
(EventBaseSet. EventName _. Contains _ ("hello"). OR _ (EventBaseSet. Days _. BiggerThan _ (22 ));

Nested Query

DBTool db = new DBTool (Table. EventBaseSet );
Db. Where = EventBaseSet. Creater_CreaterID _. Equals _ (CreaterSet. CreaterID _. SelectFrom _ (Table. CreaterSet). Where _(
CreaterSet. Name _. Repeated SSTR _ ("")));

Custom object query (including multi-Table query)
Var SQL = "Copied SQL statement ";

Var data = DBTool. Database. GetEntity <custom entity> (SQL );

Data insertion

DBTool db = new DBTool (Table. CitySet); // db. StartTransaction = true; // whether to enable transaction db. SetInsertField (CitySet. CName _, "City 1 ");
Db. SetInsertField (CitySet. CID _, "10001 ");
Db. SaveChanges ();
Var newID = db. NewID; // newly generated auto-incrementing primary key

 
Data Update operations
// Update data --------------
Db. SetUpdateField (CitySet. CName _, "City 1 ");
Db. SetUpdateField (CitySet. CID _, "1--1 ");
Db. Where =

CitySet.

CID _. Equals _ (2)
Db. SaveChanges ();
//-----------------------

 

Data deletion

Db. DeleteWhere (EventBaseSet. EventID _. Equals _ (2 ));
Db. SaveChanges ();

In addition to the above functions, I will show some of its other powerful functions.

  1.  Use the jqurey paging plug-in pagenav. min. js

    .(

<Script>
Var _ pageSum = Math. ceil (<% = ViewData ["Count"] %>/20 );
Var _ perCount = 20;
Var _ listDivID = "_ listDivID ";
Var _ listActionPlace = "MyPromotionList? IsCreate = true ";
// These are only configurations. The following can be copied.
Function GetPage (currentPageIndex, pageSum ){
..............................
});
</Script>

Call the Page code of the background.

Public List <HallPromotion> GetHallPromotionList (int startIndex, int endIndex, string orderby)
{
DBTool db = new DBTool (Table. PromotionSet );
Db. Where = "1 = 1 ";
Var count = db. GetCount ();
Var list = db. GetPageListDesc <PromotionSet> (startIndex, endIndex, orderby); // specify the index page.
Var haList = new List <PromotionSet> ();
..........
Return ret;
}

 

2. Database Upgrade problems (we often face database table changes)

Do not worry about these things in Qin. Data, because the entity is all generated by the code generator. update the database once and you regenerate the DLL (the code generator has the compilation function)

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.