C# 当不同类型的列表的属性值相等时,要从列表中排除的Linq查询?

C# 当不同类型的列表的属性值相等时,要从列表中排除的Linq查询?,c#,linq,join,C#,Linq,Join,我有一个类型费列表,我需要从中排除那些ID存在于另一个int类型列表中的类型费 List<int> ExcludedFeeIDs = new List<int>{1,2,3,4}; List<Fee> MyFees = (from c in ctx.Fees select c).ToList(); List ExcludedFeeIDs=新列表{1,2,3,4}; 列出我的费用=(从ctx.Fees中的c开始) 选择

我有一个类型费列表,我需要从中排除那些ID存在于另一个int类型列表中的类型费

List<int> ExcludedFeeIDs = new List<int>{1,2,3,4};

List<Fee> MyFees = (from c in ctx.Fees
                    select c).ToList();
List ExcludedFeeIDs=新列表{1,2,3,4};
列出我的费用=(从ctx.Fees中的c开始)
选择c.ToList();
例如: 列出GoodFees=(从ctx.Fees中的f开始,其中f.FeeID!=ExcludedFeeIDs中的一个id

请帮忙?

试试这个:

var MyFees = from c in ctx.Fees
             where !ExcludedFeeIDs.Contains(c.FeeID)
             select c;

工作得很有魅力!感谢Yannick。对于简单的查询,有些人更喜欢使用点表示法:var myFees=ctx.Fees.Where(fee=>!ExcludedFeeIDs.Contains(fee.FeeID));