sql语句转成linq

fengxuemofa6 2012-05-03 03:11:22
select SUM(P.W) as w from order o left join product p on o.pid=p.ID where o.oid=100这个sql语句怎么转成Linq啊?求教
...全文
323 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
杰拉尔 2012-07-31
  • 打赏
  • 举报
回复
select SUM(P.W) as w from order o where o.oid=100
如果是left join楼上的sql语句就可以写成这样没并要join下
dfsdbh123 2012-07-30
  • 打赏
  • 举报
回复
linq学习中......
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]

引用楼主 的回复:
select SUM(P.W) as w from order o left join product p on o.pid=p.ID where o.oid=100这个sql语句怎么转成Linq啊?求教


var query=(order.AsEnumerable().where(c=>c.oid==100)
join product.A……
[/Quote]
这种写法想深入学习阿,如果有人懂麻烦给讲解下 谢谢了
Astpiy 2012-06-12
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 的回复:]

引用 11 楼 的回复:
使用“Linqer.exe”进行转换

有破解的不?
[/Quote]

只需要连接数据库 指定你创建的.dbml就可以了
我资源里面有


wanghhyang123 2012-06-12
  • 打赏
  • 举报
回复
linq学习中......
crazyzyc 2012-06-11
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 的回复:]
使用“Linqer.exe”进行转换
[/Quote]
有破解的不?
Astpiy 2012-06-01
  • 打赏
  • 举报
回复
使用“Linqer.exe”进行转换
Astpiy 2012-06-01
  • 打赏
  • 举报
回复
你试着使用“Linqer.exe”这个工具,可以转,只需要连接数据库的字符串和指定你创建的.dbml就可以了
skydhx 2012-05-04
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
你用LINQPAD
VLinq
http://www.alinq.org/en/default.aspx
可以转!
[/Quote] 这个工具 怎么用》?
skydhx 2012-05-04
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
你用LINQPAD
VLinq
http://www.alinq.org/en/default.aspx
可以转!
[/Quote] 这个工具 怎么用》?
skydhx 2012-05-04
  • 打赏
  • 举报
回复
1楼哥们, ORDesigner 怎么用啊
q107770540 2012-05-03
  • 打赏
  • 举报
回复
[Quote=引用楼主 的回复:]
select SUM(P.W) as w from order o left join product p on o.pid=p.ID where o.oid=100这个sql语句怎么转成Linq啊?求教
[/Quote]
var query = (from o in order.Where(x=>x.oid==100)
join p in product
on o.pid equals p.ID into t
from p in t.DefaultIfEmpty()
select p.W).Sum();
你的选择B 2012-05-03
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]

引用楼主 的回复:
select SUM(P.W) as w from order o left join product p on o.pid=p.ID where o.oid=100这个sql语句怎么转成Linq啊?求教


var query=(order.AsEnumerable().where(c=>c.oid==100)
join product.A……
[/Quote]
改下:
var query=(order.AsEnumerable().where(c=>c.oid==100)
join product.AsEnumerable() on order.Field<int>("pid") equals product.Field<int>("pid")
select product.Field<int>("w")).Sum();
你的选择B 2012-05-03
  • 打赏
  • 举报
回复
[Quote=引用楼主 的回复:]
select SUM(P.W) as w from order o left join product p on o.pid=p.ID where o.oid=100这个sql语句怎么转成Linq啊?求教
[/Quote]

var query=(order.AsEnumerable().where(c=>c.oid==100)
join product.AsEnumerable() on order.Field<int>("pid") equals product.Field<int>("pid")
select product.w).Sum();
newxdlysk 2012-05-03
  • 打赏
  • 举报
回复

(from o in order
join p in product
on o.pid equals p.ID
into temp
from temp.DefaultIfEmpty
where o.oid==100
select temp.W).Sum(x=>x.W);
fengxuemofa6 2012-05-03
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

你用LINQPAD
VLinq
http://www.alinq.org/en/default.aspx
可以转!
[/Quote]有这个工具,但是不太会用啊
一克代码 2012-05-03
  • 打赏
  • 举报
回复
你用LINQPAD
VLinq
http://www.alinq.org/en/default.aspx
可以转!

8,497

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 LINQ
社区管理员
  • LINQ
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧