如何在Linq中编写In子句 [英] How to write In clause in Linq

查看:273
本文介绍了如何在Linq中编写In子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从ProductMaster中选择*,其中ProductID为(从SuppliersHotelsInfo中选择LocHotelID,其中SearchID = 227)





i想写同样的声明在linq

解决方案

你可以尝试这个...

 List <   string  >  statusID = new List <   string  > (){4, 5\" , 6, 7}; 

var results = from cs in Product.CastStatus
where statusID.Contains(cs.CastStatusID)
select cs;


看到这个.. :)



LINQ中的IN子句 [ ^ ]



LINQ to Entities - 查询中的IN子句[重复] [ ^ ]



如何使用' linq中的IN'子句 [ ^

select * from ProductMaster where ProductID in (select LocHotelID from SuppliersHotelsInfo where SearchID=227)


i want to write the same statement in linq

解决方案

you can try this one...

List<string> statusID = new List<string>() {"4","5","6","7"};

var results = from cs in Product.CastStatus
              where statusID.Contains(cs.CastStatusID)
              select cs;


see this.. :)

Where IN clause in LINQ[^]

LINQ to Entities - Where IN clause in query [duplicate][^]

HOW TO USE 'IN' clause in linq [^]


这篇关于如何在Linq中编写In子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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