C#在集合中使用lamda更改某字段的值并返回新的集合
1、在集合purList中把PurchaseId统一替换成某个值keyValue并重新返回一个新集合:
var purListData = purList.Select(p => { p.PurchaseId = keyValue; return p; });
2、在lamda中使用判断语句替换集合中某一特定值并返回新的集合:
var invoiceData = db.Where(i => i.InvoiceId == derId).ToList().Select(i => { if (i.InvoiceId == invoiceId) i.InvoiceState = invoiceState; return i; });
微信号:jamesworkshop 学习QQ群:364976091