AEF was born-detailed explanation of query syntax

Source: Internet
Author: User

LINQ to Entity query syntax
Allows developers to query the Object Context of EDM in a strongly-typed manner using the LINQ expressions and the standard LINQ expressions.
Standard query expression method in LINQ to Entity
1. Projection Methods)
Select, selectworkflow
2. Filtering Methods)
Where
3. Join Methods)
Join and GroupJoin
4. Set Methods)
All, Any, Concat, Contains, DefaultIfEmpty, Distinct, Except All, Except T, Insertset, Union
5. Ordering Methods)
OrderBy, OrderByDescending, ThenBy, ThenByDescending, Reverse
6. Grouping Methods)
GroupBy
7. Aggregate Methods)
Aggregate, Average, Count, LongCount, Max, Min, Sum
8. Type Method)
Convert, OfType
9. Paging Methods)
ElemeAt, First, FirstOrDefault, Last, LastOrDefault, Single, Skip, Take, TakeWhile

Entity SQL query syntax

Standard Functions
1. Aggregate Standard Functions)
Avg, BigCount, Count, Max, Min, StDev, Sum
2. Math Functions)
Abs, Ceiling, Floor, Round
3. String standard Functions (Sting Functions)
Concat, IndexOf, Left, Length, LTrim, Replace, Reverse, Right, RTrim, Substring,
ToLower, ToUpper, Trim
4. Date & Time Functions
Year, Month, Day, Hour, Minute, Second, Millisecond, CurrentDateTime, CurrentDateTimeOffset
5. Bitwise Functions
BitWiseAnd, BitWiseNot, BitWiseOr, BitWiseXor
6. Standard Functions (Other Canonical Functions)
NewGuid
7. Relationship Navigation Operator)
8. Reference Operators)
9. Arithmetic expressions (Arithmetic Operators)
10. Comparison Operators)
11. Logical operation expressions (Logical Operators)
12. String Concatenation Operator
13. Type Operators)
14. Case Expression)
15. Set Operators)
16. Type Constructor Operators)
17. Query Expressions)
Go deep into the Query Builder Methods Query syntax ~ ObjectQuery Method
Distinct
Except
GroupBy
Intersect
OfType
OrderBy
Select
SelectValue
Skip
Top
Union
UnionAll
Where

Qurey Builder Methods query syntax

 

Code

 1  using (NorthwindModel.NorthwindEntities nwEntity = new NorthwindModel.NorthwindEntities())
2 {
3 ObjectQuery<DbDataRecord> employees = nwEntity.Employees.Select("it.EmployeeID," +
4 "it.LastName," + "it.City," + "it.Country").Where("it.Country='USA'");
5
6 gvEmployees.DataSource = employees;
7 gvEmployees.DataBind();
8 }

 

 

Three Entity Fx useful tips
Effectively control the query syntax after conversion
Query syntax after view Conversion
Increase query efficiency by compiling and caching
1. here we can use the ToTraceString () method to view the converted T-SQL syntax.

2. The pre-compiled method can effectively reduce the execution time of the program.

Code

 1 using (NorthwindModel. NorthwindEntities nwContext = new NorthwindModel. NorthwindEntities ())
2 {
3 // create an Entity SQL query string
4 string esql = @ "Select Value Employees from NorthwindEntities. Employees ";
5
6 // query with ObjectQuery
7 ObjectQuery <NorthwindModel. Employees> employees = new ObjectQuery <NorthwindModel. Employees> (esql, nwContext, MergeOption. NoTracking );
8
9 gvEmployees. DataSource = employees;
10 gvEmployees. DataBind ();
11}

 

 

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.