Farseer.net Lightweight Open Source Framework primer: query data in detail

Source: Internet
Author: User

Navigation

Catalog: Farseer.net Lightweight Open source Framework Catalog

Previous: Farseer.net lightweight open source framework Getting started: deleting data in detail

Several ways to query a list
1         // field value specified plus 1 2         1). ToList ();
1         // Query the first 10 data 2         Users.Data.ToList (ten);
1         // Bulk Query 2         var New list<int12345  }; 3         Users.Data.ToList (LST);
1         // Query 2nd page, show 20 per page (page) 2         Users.Data.ToList (2);
1         // Query 5th page, show 10 per page (page) 2         int recordCount;    // Total Records 3         Users.Data.ToList (out5);
1         // reduce database pressure, show only username, password fields 2         New {o.username, O.password}). ToList ();
1         //Fuzzy search + Advanced Search2         varKeywords ="";3         varBean = Users.data;//can also be: var bean = User.Data.Select (o = = new {o.username, o.password})4Bean. Where (o = o.id >1);5         if(keywords. Ishaving ()) {bean. Where (o = o.username.contains (keywords)); }//Fuzzy Search When keywords has value6         //actions that can be added to or7Bean. Whereor (o = O.roleid = =2);8         varLST = Bean. ToList ();
1         // If you're too tolist slow (reflection to an entity, you can return only a DataTable 2         Users.Data.ToTable ();
1         // bulk queries, descending by ID 2         Users.Data.Desc (o = o.id). ToList (); 3 4         // batch query, by ID, UserName ascending 5         New {o.id,o.username}). ToList ();
1         // return random Records 2         Users.Data.ToListByRand ();
1         // The result returned here is not an entity, it is a list of identity IDs.  2         //  For example, the possible return is: 1,2,3,43         Users.Data.ToSelectList ();
Several ways to query a single record
1         // find a single record of id = = 1 2         Users.Data.ToInfo (1);
1         // next piece of data with ID 1 (usually the concept of the next article) 2         Users.Data.ToNextInfo (1);
1         // previous data with ID 2 (usually the concept of the previous article) 2         Users.Data.ToPreviousInfo (2);
Several ways to query single values and aggregation
1         // total number of records returned 2         6). Count ();
1         // returns the maximum ID 2         Users.Data.GetMax (o = o.id);
1         // returns the minimum number of IDs 2         Users.Data.GetMin (o = o.id);
1         // returns the cumulative number of IDs 2         Users.Data.GetSum (o = o.id);
1         // returns the user name (here is the string type)2         Users.Data.GetValue (o = o.username);
1         // determine if a value exists 2         1). Ishaving ();
Navigation

Catalog: Farseer.net Lightweight Open source Framework Catalog

Previous: Farseer.net lightweight open source framework Getting started: deleting data in detail

Farseer.net Lightweight Open Source Framework primer: query data in detail

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.