C# 如何使用LINQ to SQL从ID值列表中获取结果列表?

C# 如何使用LINQ to SQL从ID值列表中获取结果列表?,c#,linq,linq-to-sql,C#,Linq,Linq To Sql,我有一个ID值列表: List<int> MyIDs { get; set; } 在这里,我遍历myid,传入每个id,并将每个结果添加到列表中 我需要如何更改LINQ,以便传入完整的MyID列表并输出MyType列表?GetMyTypes()的签名类似于 public List<MyType> GetMyTypes(List<int> myIds) 公共列表GetMyTypes(列表MyID) 未经测试 public List<MyType>

我有一个ID值列表:

List<int> MyIDs { get; set; }
在这里,我遍历myid,传入每个id,并将每个结果添加到列表中

我需要如何更改LINQ,以便传入完整的MyID列表并输出MyType列表?GetMyTypes()的签名类似于

public List<MyType> GetMyTypes(List<int> myIds)
公共列表GetMyTypes(列表MyID)
未经测试

public List<MyType> GetMyTypes(List<int> myIds) {
  var x = from myType in db.MyTypes
          where myIds.contains(myType.Id)
          select new MyType {
            MyValue = mytype.Myvalue
          };
return x.ToList();
}
公共列表GetMyTypes(列表MyID){
var x=从db.MyTypes中的myType开始
其中myIds.contains(myType.Id)
选择新的MyType{
MyValue=mytype.MyValue
};
返回x.ToList();
}
公共列表GetMyTypes(列表ID)
{
返回(从db.MyTypes中的myType返回)
其中ids.Contains(myType.Id)
选择新的MyType
{
MyValue=myType.MyValue
}).ToList();
}

此问题的副本已存在4.5年。。。你觉得无聊吗?是的,我很无聊,但这与发表评论来帮助其他人没有任何关系,这些人最终也在这里寻求帮助来解决这个问题。
public List<MyType> GetMyTypes(List<int> myIds)
public List<MyType> GetMyTypes(List<int> myIds) {
  var x = from myType in db.MyTypes
          where myIds.contains(myType.Id)
          select new MyType {
            MyValue = mytype.Myvalue
          };
return x.ToList();
}
public List<MyType> GetMyTypes(List<int> ids)
{
return (from myType in db.MyTypes
        where ids.Contains(myType.Id)
        select new MyType
        {
            MyValue = myType.MyValue
        }).ToList();
}