我得到约等于49000的业务实体(表数据)的集合。我想一定值从这个集合使用添加方法和手动添加值的属性从一种类型的集合复制到另一种类型的最快方法c#
例如 //返回arounf 49000 VendorProduct收集这是指表中的数据VendorProduct复制到哪吒收集
List<VendorProduct> productList = GetMultiple(req);
foreach (VendorProduct item in productList)
{
VendorSearchProductWrapper wrapperItem = new VendorSearchProductWrapper();
IEnumerable<ClientProductPreference> prodPrefClient = item.ClientProductPreferences.Where(e => (e.VendorProductId.Equals(item.Id)
&& (e.AccountId.Equals(SuiteUser.Current.AccountId))));
if (prodPrefClient.Count() == 1)
{
foreach (ClientProductPreference it in prodPrefClient)
{
wrapperItem.ClientProdID = it.Id;
wrapperItem.ClientProductDescription = it.Description;
wrapperItem.MarkupPct = it.MarkUpPct;
wrapperItem.SalesPrice = it.SalesPrice;
}
}
wrapperItem.Code = item.Code;
wrapperItem.ListPrice = item.ListPrice;
wrapperItem.Id = item.Id;
wrapperItem.DiscountPct = ValueParser.SafeDecimal(item.Discount, null);
wrapperItem.Discountgroup = item.DiscountGroup.DiscountGroup;
wrapperItem.Description = item.Description;
wrapperItem.Unit = item.Unit;
wrapperItem.ClientName = item.Account.ClientName;
products.Add(wrapperItem);
}
要复制所有这些49000条记录,它需要很多时间。实际上5分钟只有100-200条记录被添加到列表中。
我需要在大约1分钟内快速复制这些值。
在此先感谢
弗朗西斯P.