S
Sudip_inn
Guest
please see my code and tell me AsParallel would make sense to populate list from datatable. if i use AsParallel then does it speed up the job to populate list<T> from data table when datatable has huge data ?
DataTable dtBogeylist = Get10QKLiConfigData();
List<QCHelper> BogeyConfigList = (from bogyconfiglist in dtBogeylist.AsEnumerable().AsParallel()
select new QCHelper()
{
Section = bogyconfiglist.Field<string>("Section").ToString().Trim(),
Li = bogyconfiglist.Field<string>("LineItem").ToString().Trim(),
xFundCode = bogyconfiglist.Field<string>("XFundCode").ToString().Trim(),
AllowComma = (bogyconfiglist.Field<string>("AllowComma") == null ? false : Convert.ToBoolean((bogyconfiglist.Field<string>("AllowComma").ToString() == string.Empty ? false : Convert.ToBoolean(bogyconfiglist.Field<string>("AllowComma").ToString().Trim())))),
AllowPercentageSign = (bogyconfiglist.Field<string>("AllowPercentageSign") == null ? false : Convert.ToBoolean((bogyconfiglist.Field<string>("AllowPercentageSign").ToString() == string.Empty ? false : Convert.ToBoolean(bogyconfiglist.Field<string>("AllowPercentageSign").ToString().Trim())))),
IsQcCheck = (bogyconfiglist.Field<string>("QCCheck") == null ? false : (bogyconfiglist.Field<string>("QCCheck").ToString() == string.Empty ? false : Convert.ToBoolean(bogyconfiglist.Field<string>("QCCheck").ToString().Trim()))),
AllowedDecimalPlace = (bogyconfiglist.Field<string>("AllowedDecimalPlace") == null ? "" : bogyconfiglist.Field<string>("AllowedDecimalPlace").ToString().Trim()),
CurrencySign = (bogyconfiglist.Field<string>("CurrencySign") == null ? "" : bogyconfiglist.Field<string>("CurrencySign").ToString().Trim()),
QcType = (bogyconfiglist.Field<string>("QCType") == null ? "" : bogyconfiglist.Field<string>("QCType").ToString().Trim()),
FormulaLiConfig = (bogyconfiglist.Field<string>("StandrdFormula") == null ? "" : bogyconfiglist.Field<string>("StandrdFormula").ToString().Trim()),
CrossCalc1Q = (bogyconfiglist.Field<string>("CrossCalc1Q") == null ? "" : bogyconfiglist.Field<string>("CrossCalc1Q").ToString().Trim()),
CrossCalc2Q = (bogyconfiglist.Field<string>("CrossCalc2Q") == null ? "" : bogyconfiglist.Field<string>("CrossCalc2Q").ToString().Trim()),
CrossCalc1H = (bogyconfiglist.Field<string>("CrossCalc1H") == null ? "" : bogyconfiglist.Field<string>("CrossCalc1H").ToString().Trim()),
CrossCalc3Q = (bogyconfiglist.Field<string>("CrossCalc3Q") == null ? "" : bogyconfiglist.Field<string>("CrossCalc3Q").ToString().Trim()),
CrossCalc4Q = (bogyconfiglist.Field<string>("CrossCalc4Q") == null ? "" : bogyconfiglist.Field<string>("CrossCalc4Q").ToString().Trim()),
CrossCalc2H = (bogyconfiglist.Field<string>("CrossCalc2H") == null ? "" : bogyconfiglist.Field<string>("CrossCalc2H").ToString().Trim()),
CrossCalcFY = (bogyconfiglist.Field<string>("CrossCalcFY") == null ? "" : bogyconfiglist.Field<string>("CrossCalcFY").ToString().Trim())
}).DistinctBy(a => new { a.Section, a.Li }).ToList<QCHelper>();
this way i used AsParallel
from bogyconfiglist in dtBogeylist.AsEnumerable().AsParallel()
please give me suggestion thanks
Continue reading...
DataTable dtBogeylist = Get10QKLiConfigData();
List<QCHelper> BogeyConfigList = (from bogyconfiglist in dtBogeylist.AsEnumerable().AsParallel()
select new QCHelper()
{
Section = bogyconfiglist.Field<string>("Section").ToString().Trim(),
Li = bogyconfiglist.Field<string>("LineItem").ToString().Trim(),
xFundCode = bogyconfiglist.Field<string>("XFundCode").ToString().Trim(),
AllowComma = (bogyconfiglist.Field<string>("AllowComma") == null ? false : Convert.ToBoolean((bogyconfiglist.Field<string>("AllowComma").ToString() == string.Empty ? false : Convert.ToBoolean(bogyconfiglist.Field<string>("AllowComma").ToString().Trim())))),
AllowPercentageSign = (bogyconfiglist.Field<string>("AllowPercentageSign") == null ? false : Convert.ToBoolean((bogyconfiglist.Field<string>("AllowPercentageSign").ToString() == string.Empty ? false : Convert.ToBoolean(bogyconfiglist.Field<string>("AllowPercentageSign").ToString().Trim())))),
IsQcCheck = (bogyconfiglist.Field<string>("QCCheck") == null ? false : (bogyconfiglist.Field<string>("QCCheck").ToString() == string.Empty ? false : Convert.ToBoolean(bogyconfiglist.Field<string>("QCCheck").ToString().Trim()))),
AllowedDecimalPlace = (bogyconfiglist.Field<string>("AllowedDecimalPlace") == null ? "" : bogyconfiglist.Field<string>("AllowedDecimalPlace").ToString().Trim()),
CurrencySign = (bogyconfiglist.Field<string>("CurrencySign") == null ? "" : bogyconfiglist.Field<string>("CurrencySign").ToString().Trim()),
QcType = (bogyconfiglist.Field<string>("QCType") == null ? "" : bogyconfiglist.Field<string>("QCType").ToString().Trim()),
FormulaLiConfig = (bogyconfiglist.Field<string>("StandrdFormula") == null ? "" : bogyconfiglist.Field<string>("StandrdFormula").ToString().Trim()),
CrossCalc1Q = (bogyconfiglist.Field<string>("CrossCalc1Q") == null ? "" : bogyconfiglist.Field<string>("CrossCalc1Q").ToString().Trim()),
CrossCalc2Q = (bogyconfiglist.Field<string>("CrossCalc2Q") == null ? "" : bogyconfiglist.Field<string>("CrossCalc2Q").ToString().Trim()),
CrossCalc1H = (bogyconfiglist.Field<string>("CrossCalc1H") == null ? "" : bogyconfiglist.Field<string>("CrossCalc1H").ToString().Trim()),
CrossCalc3Q = (bogyconfiglist.Field<string>("CrossCalc3Q") == null ? "" : bogyconfiglist.Field<string>("CrossCalc3Q").ToString().Trim()),
CrossCalc4Q = (bogyconfiglist.Field<string>("CrossCalc4Q") == null ? "" : bogyconfiglist.Field<string>("CrossCalc4Q").ToString().Trim()),
CrossCalc2H = (bogyconfiglist.Field<string>("CrossCalc2H") == null ? "" : bogyconfiglist.Field<string>("CrossCalc2H").ToString().Trim()),
CrossCalcFY = (bogyconfiglist.Field<string>("CrossCalcFY") == null ? "" : bogyconfiglist.Field<string>("CrossCalcFY").ToString().Trim())
}).DistinctBy(a => new { a.Section, a.Li }).ToList<QCHelper>();
this way i used AsParallel
from bogyconfiglist in dtBogeylist.AsEnumerable().AsParallel()
please give me suggestion thanks
Continue reading...