我得到約等於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.