It can be seen that the final transfer to the command tree and then converted to the database of T-SQL statements, there is little difference in nature, but sometimes the execution of special query statements is somewhat different, because the Entity SQL T-statement is our own definition, and LINQ to Entity the last converted T-SQL statement was converted by the entity engine, and sometimes when we use SQL Server Profiler to detect executed SQL statements, the SQL executed by LINQ to entity often makes it difficult for us to understand, so there is a need for some queries/modifications/ If you find that execution is inefficient when you perform an update, consider using Entity SQL to execute the SQL statement, and then post a dot code below:
1.LINQ to Entity
String city = "London";
using (entities entities = new entities ())
{
var query = from C in entities. Customers
where c.address.city = = City
select C;
foreach (Customers C in Query)
Console.WriteLine (c.companyname);
}
2.Entity SQL (Note SQL statement OH)
String city = "London";
using (entities entities = new entities ())
{
objectquery<customers> query = entities. Createquery<customers> (
"select VALUE C from Customers as C WHERE c.address.city = @city", New objectparameter< c14/> ("city")
;
foreach (Customers C in Query)
Console.WriteLine (c.companyname);
}