MasterofProject

To Entities LINQ, the query will be converted to ordinary SQL statement

Label LINQSQLQueryNullString
2072 people read comments(5) Collection Report
Classification:
Using (MyEntity testEntities = testEntities new ())
{
LINQ to entities #region content exercise 3

Result var = s in MyEntity.stuinfo from
Where s.username = = "pkm"
New select
{
Username=s.username,
Age=s.age
};
Var = result.GetType (PSQL).GetMethod (ToTraceString).Invoke (result, null); / / get the original SQL statement
                
Console.WriteLine (PSQL);
#endregion
}


 

 

The following functions can get the same results:

/ / / <summary>
The SQL statement generated input / / /
/ / / </summary>
Name= "T" ></typeparam> / / / <typeparam
<param name= "query" > / / / query result variable </param>
/ / / <returns></returns>
Static string GetSQL<T> private (query IQueryable<T>)
{
Query.GetType.GetMethod () ("ToTraceString").Invoke (query, null).ToString () () () return () ();
}
Please use the method of Console.WriteLine / (GetSQL (result));


 

top
Zero
tread
Zero
Guess you're looking for
View comments
* the above user comments only represent their personal views, does not represent the views or position of the CSDN website
    personal data
    • Visit374774 times
    • Integral:Six thousand one hundred and four
    • Grade
    • Rank:2119th name
    • Original233
    • Reproduced:18
    • Translation:11
    • Comments:115
    Site search
    Latest comments