我有一個過程,我在列表中標識行(unmatchedClient),然後調用一個單獨的方法刪除它們(pingtree.RemoveNodes)。這似乎有點冗長,我只需將屬性「DeleteFlag」的值設置爲true即可實現同樣的效果。但是,如何使用linq設置值?這可以完全通過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);
在此先感謝。
(http://stackoverflow.com/questions/16594544/assigning-values-inside-a-linq-select/16594770#16594770)選擇一個解決方案之前,請考慮答案的問題[一個LINQ選擇內部分配值?]你的問題 –