Ang*_*Bad 0 linq generics c#-3.0
我有两个ILIst这些对象:
class ProductionMachineType
{
string code { get; set; }
IEnumerable<string> ProductionToolsLink { get; set; }
}
class ProductionTools
{
string code { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我正在寻找一个快速的Linq方法,使我能够查询IList<ProductionMachineType>包含至少一个ProductionToolsLink包含在里面的内容ILIst<ProductionTools>.
在SQL中,我会这样:
SELECT
*
FROM
IList<ProductionMachineType>
WHERE
IList<ProductionMachineType>.ProductionToolsLink IN ILIst<ProductionTools>
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点?
Contains方法可以帮助你:
var names = new string[] { "Alex", "Colin", "Danny", "Diego" };
var matches = from person in people
where names.Contains(person.Firstname)
select person;
Run Code Online (Sandbox Code Playgroud)