由网友(阳光洒进那一抹的凄凉)分享简介:我要翻译LINQ EX pression树的SQL语句,我不想写我自己的code这一点。例如:VAR的查询=从C的客户其中,c.Country ==英国和安培;&安培;c.City ==伦敦选择C);要SELECT ... FROM客户为C,其中c.Country =英国和c.City =伦敦我知道 DataC...![LINQ体验 6 LINQ to SQL语句之Join和Order By](https://p.xsw88.cn/allimgs/daicuo/20230902/822.png)
我要翻译LINQ EX pression树的SQL语句,我不想写我自己的code这一点。
例如:
VAR的查询=从C的客户
其中,c.Country ==英国和安培;&安培;
c.City ==伦敦
选择C);
要
SELECT ... FROM客户为C,其中c.Country =英国和c.City =伦敦
我知道 DataContext.Log
,但我想用:
query.ToSqlStatementString()
![LINQ体验 6 LINQ to SQL语句之Join和Order By](https://p.xsw88.cn/allimgs/daicuo/20230902/822.png)
解决方案
CustomDataContext DC =新CustomDataContext();
IQueryable的<客户>查询=
从C在dc.Customer
其中,c.Country ==UK
选择C;
//
字符串命令= dc.GetCommand(查询).CommandText;
I want to translate LINQ expression tree to SQL statement and I don't want to write my own code for this.
Example:
var query = from c in Customers
where c.Country == "UK" &&
c.City == "London"
select c);
To
SELECT ... FROM Customers AS c WHERE c.Country = "UK" AND c.City = "London"
I know DataContext.Log
, but I want to use:
query.ToSqlStatementString()
解决方案
CustomDataContext dc = new CustomDataContext();
IQueryable<Customer> query =
from c in dc.Customer
where c.Country == "UK"
select c;
//
string command = dc.GetCommand(query).CommandText;
相关推荐
最新文章