C# LINQ List<T>.ForEach迭代器扩展方法
ForEach 扩展方法
C# 全选
public static partial class IEnumerableExtensions
{
/// <summary>
/// 迭代器
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="list">实体列表</param>
/// <param name="func">处理函数</param>
public static void ForEach<T>(this IEnumerable<T> list, Action<T> func)
{
foreach (var item in list)
{
func(item);
}
}
}
使用方法
C# 全选
//关联更新数据
(from a in listResult
join b in listApprovalList on a.NodeId equals b.NodeId
select new { a, b }).ForEach(item =>
{
item.a.ApprovalComments = item.b.ApprovalComments;
item.a.ApprovalTime = item.b.ApprovalTime;
item.a.ApprovalStatus = item.b.ApprovalStatus;
item.a.ApprovalUserId = item.b.ApprovalUserId;
});
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
CSFramework.EF C/S框架网