Commonly used Writing Method of LINQ

Source: Internet
Author: User

1. datatable

Datatable dt = UDB. getalluser ();
Datatable dt1 = new datatable ();

Ienumerable <datarow> Q1 = from R in DT. asenumerable ()

Where R. Field <int> ("workshop ID") = convert. toint32 (workshop ID) & R. Field <int> ("isadmin") = 0
Orderby R. Field <int> ("workshop ID") Ascending
Select R;
Dt1 = q1.copytodatatable ();

R. Field <int> ("workshop ID"). Convert. toint32 (R ["workshop ID"])

2. List

List <dic_rela_railline_node> selectget =
(From X in dic_rela_railline_nodes
Where X. sub_line_id = railtracklines [I]. r_id.tostring ()
Orderby X. center_kilo ascending
Select X). tolist ();

Paging Method

Ienumerable <datarow> Q1 = (from R in DT. asenumerable ()

Orderby R. Field <int> ("ID") Ascending
Select R). Skip (startindex-1). Take (pagesize );

Skip and take

 

Use VaR

VaR Q1 = (from R in cus

Orderby R. createtime ascending

Select R). Skip (startindex-1). Take (pagesize );

List <common_user> cus2 = new list <common_user> (); cus2 = q1.tolist ();

 

 

 
VaRQuery =FromLInColor s
Group LNew{L. Color ID} into G
Select New
{

Color id = G. Key. Color ID,
Score = G. sum (O => O. Score)
};
 
DoubleQ = dB. menuinfo. Where (P => P. PID = PID). Max (P => P. iorder );

 

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.