我在变异的SI中有一些像下面这样的对象。我正在尝试使用ods.tblSoftwareImages
查找另一个表SoftwareImageId
,并从表SoftwareImage
获取所有ods.tblSoftwareImages
的列表。任何人都可以就如何做到这一点提供指导吗?
SIs
[
{
"ProductLineID": 17646,
"SoftwareImageId": 17646,
"SoftwareProductId": "2032882"
},
{
"ProductLineID": 17646,
"SoftwareImageId": 17646,
"SoftwareProductId": "2032881"
},
{
"ProductLineID": 17645,
"SoftwareImageId": 17645,
"SoftwareProductId": "2032883"
}
]
public IEnumerable<SoftwareImage> GetSIForSP(int SoftwareProductID)
{
var SIs = _entities.tblSoftwareProductSoftwareImages
.Where(x =>x.SoftwareProductId == SoftwareProductID).ToList();
return null;
}
答案 0 :(得分:1)
您可以从SI中选择imageIds并在这些ID上的图像表中查询。 只是示例代码:我不确切知道您的表的名称以及Id属性的样子。
public IEnumerable<SoftwareImage> GetSIForSP(int SoftwareProductID)
{
var imageIds = _entities.tblSoftwareProductSoftwareImages
.Where(x =>x.SoftwareProductId == SoftwareProductID)
.Select(x=>x.SoftwareImageId)
.ToList();
var images = _entities.tblSoftwareImages
.Where(x=>imageIds.Contains(x.SoftwareImageId));
return images;
}