C# 如何在多表中选择价格大于“0”的单列?

C# 如何在多表中选择价格大于“0”的单列?,c#,linq,C#,Linq,我有5张表格,如下所示: 城市 特布尔酒店 酒店客房 转移 邮轮 我想写下一个QueryLink,它将返回一个没有重复记录的城市代码列表,其中至少有一个记录,其中表Hotel_TBL、Transfer_TBL、Cruise_TBL和HotelRoom_TBL中的字段/列价格大于“0”,如下所示: Result_TBL 如何使用LINQtoSQL实现这一点 非常感谢您的关注 祝你玩得愉快 干杯 对不起,我修改了问题,因为我忘了写下另一张桌子,所以请原谅我这个错误。 非常感谢也许 var data

我有5张表格,如下所示:

城市

特布尔酒店

酒店客房

转移

邮轮

我想写下一个QueryLink,它将返回一个没有重复记录的城市代码列表,其中至少有一个记录,其中表Hotel_TBL、Transfer_TBL、Cruise_TBL和HotelRoom_TBL中的字段/列价格大于“0”,如下所示:

Result_TBL
如何使用LINQtoSQL实现这一点

非常感谢您的关注

祝你玩得愉快

干杯

对不起,我修改了问题,因为我忘了写下另一张桌子,所以请原谅我这个错误。 非常感谢

也许

var data = 
    ctx.HotelTbl.Where(row => row.Price > 0).Select(row => row.CityCode)
    .Union(
     ctx.TransferTbl.Where(row => row.Price > 0).Select(row => row.CityCode)
    ).Union(
     ctx.ResultTbl.Where(row => row.Price > 0).Select(row => row.CityCode)
    );
但就个人而言,我很想使用ExecuteQuery:

var data = ctx.ExecuteQuery<string>(@"
select CityCode from Hotel_Tbl where Price > 0
union select CityCode from Transfer_Tbl where Price > 0
union select CityCode from Result_Tbl where Price > 0").ToList();

非常感谢Marc先生,代码是正确的,但我忘记插入另一张表,因此请尝试对我的错误表示同情。是的,Marc,这非常好…非常感谢您的支持,祝您度过愉快的一天。
    1                   ABB              0
    2                   ABB              10
    3                   FRI              0
    4                   DET              0
    5                   ROM              19
RoomID         HotelCode (FK)      RoomName     Price
    1                   1          Superior       3
    2                   2          DeLuxe         6
    3                   1          Panoramic      0
    4                   3          Suite          0
    5                   4          Presidential   1
TransferCode         CityCode (FK)      Price
    1                   ABB              3
    2                   ABB              6
    3                   DET              0
    4                   FRI              0
CruiseCode         CityCode (FK)      Price
    1                   ABB              3
    2                   DET              0
    3                   FRI              0
    4                   ROM              0 
Result_TBL
   ABB
   ROM
var data = 
    ctx.HotelTbl.Where(row => row.Price > 0).Select(row => row.CityCode)
    .Union(
     ctx.TransferTbl.Where(row => row.Price > 0).Select(row => row.CityCode)
    ).Union(
     ctx.ResultTbl.Where(row => row.Price > 0).Select(row => row.CityCode)
    );
var data = ctx.ExecuteQuery<string>(@"
select CityCode from Hotel_Tbl where Price > 0
union select CityCode from Transfer_Tbl where Price > 0
union select CityCode from Result_Tbl where Price > 0").ToList();