如何将此Linq转换为Sql [英] How Do I Convert This Linq To Sql

查看:58
本文介绍了如何将此Linq转换为Sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨2每个人

i想要将此linq查询更改为sql

 from  d  in  Context.OrderDetails 
join p in 关于d.ProductID的Context.Products等于p.ProductID
其中​​ d.OrderID == orderid
选择 new
{
d.DetailID,
p.ProductTitle,
d.ProductCount,
p.ProductPrice,
Psum =( from da in Context.OrderDetails 其中 da.DetailID == d.DetailID select da.ProductCount * da.ProductPrice).FirstOrDefault()
})。ToList();

解决方案

你看过LinqPad LinqPad [ ^ ]?



这是一个免费的实用工具使用Linq,它会将Linq转换为Sql。



我在大多数情况下使用它代替Sql Manager。


你可以在visual studio调试器本身看到查询,只需在该查询中放置一个断点并运行它。当它到达断点时,只需检查它。你可以看到在后台生成的查询。基本上,当我们运行linq查询时,匹配的sql查询是在我们不知道的后台生成的。



请参阅此链接 [ ^

hi 2 everybody
i want change this linq query to sql

(from d in Context.OrderDetails
                        join p in Context.Products on d.ProductID equals p.ProductID
                        where d.OrderID==orderid
                        select new
                            {
                                d.DetailID,
                              p.ProductTitle,
                              d.ProductCount,
                              p.ProductPrice,
                                Psum = (from da in Context.OrderDetails where da.DetailID == d.DetailID select da.ProductCount * da.ProductPrice).FirstOrDefault()
                            }).ToList();

解决方案

Have you looked at LinqPad LinqPad[^]?

This is a free utility for using Linq and it will convert the Linq to Sql.

I use it instead of Sql Manager in most cases.


You can see the query in visual studio debugger itself, just put a break point in that query and run it. when it hits the break point, just check it. you can see the query generated in the background.Basically while we run a linq query, the matching sql query is generated at the background that we are not aware of.

Please refer this Link[^]


这篇关于如何将此Linq转换为Sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆