gpt4 book ai didi

c# - 这可以完全通过 linq 完成吗?

转载 作者:太空宇宙 更新时间:2023-11-03 17:54:02 25 4
gpt4 key购买 nike

我有一个过程,在这个过程中我识别列表中的行 (unmatchedClient),然后调用一个单独的方法来删除它们 (pingtree.RemoveNodes)。这似乎有点啰嗦,我可以通过将属性“DeleteFlag”的值设置为 true 来实现同样的目的。但是如何使用 linq 设置值?

var unmatchedClient = pingtree.Nodes.Where(x =>
_application.LoanAmount < x.Lender.MinLoanAmount ||
_application.LoanAmount > x.Lender.MaxLoanAmount ||
_application.LoanTerm < x.Lender.MinLoanTerm ||
_application.LoanTerm > x.Lender.MaxLoanTerm)
.Select(x => x.TreeNode)
.ToList();

pingtree.RemoveNodes(unmatchedClient);

提前致谢。

最佳答案

像这样?

pingtree.Nodes.Where(x =>
_application.LoanAmount < x.Lender.MinLoanAmount ||
_application.LoanAmount > x.Lender.MaxLoanAmount ||
_application.LoanTerm < x.Lender.MinLoanTerm ||
_application.LoanTerm > x.Lender.MaxLoanTerm)
.Select(x => x.TreeNode)
.ToList()
.ForEach(n=> n.DeleteFlag = true);

关于c# - 这可以完全通过 linq 完成吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16632658/

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