在linq中转换sql查询 [英] Converting the sql query in linq

查看:71
本文介绍了在linq中转换sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是linq的新手,我正在使用子查询。我想将下面的sql查询转换为linq查询。





I am new to linq,i am using sub query.I want to convert the below sql query into linq query.


Select [Color] from [eshop_db].[dbo].[ProductInfoView] where [ProductID] in(
Select ProductId from [old_eshop_db].[dbo].[ProductMaster] where [SKU] in (
Select [SKU] from [old_eshop_db].[dbo].[ProductMaster] where ProductId=956));





请任何人帮帮我。



Please any body help me out.

推荐答案

使用像 LINKPad [ ^ ]。学习,练习,使用!
Use tools like LINKPad[^]. Learn, practice, use!


尝试如下:

try like below:
var Color = FROM P IN ProductMaster
JOIN Co IN
    (
        FROM C IN ProductInfoView SELECT new {Color=C.Field<string>("Color"), ProducID=C.Field<int>("ProductID")}
    ) 
ON Co.ProducTID Equals P.Field<int>("ProducID) 
WHERE P.Field<int>("ProductID")==956
SELECT Co.Color;





希望它有效。



hope it works.


这篇关于在linq中转换sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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