gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 19:59:13 25 4
gpt4 key购买 nike

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

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

List<Fee> MyFees = (from c in ctx.Fees
select c).ToList();

例子:List GoodFees = (from f in ctx.Fees where f.FeeID!=ExcludedFeeIDs中的ID之一);

请帮忙?

最佳答案

试试这个:

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

关于c# - 当不同类型的列表的属性值相等时,从列表中排除的 Linq 查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1445845/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com