See how my code. where i am joining two datatable and stored the result set into List<T>
List<QCHelper> BogeyConfigList = null;
BogeyConfigList = (from bogyconfiglist in Bogeylist.AsEnumerable().AsParallel()
join LiList in list.AsEnumerable().AsParallel()
on new
{
val = bogyconfiglist.LineItem.Trim().ToUpper(),
val1 = bogyconfiglist.Section.Trim().ToUpper()
}
equals new
{
val = LiList.LI.Trim().ToUpper(),
val1 = LiList.Section.Trim().ToUpper()
}
into conbogylist
from confg in conbogylist.DefaultIfEmpty()
select new QCHelper()
{
Section = bogyconfiglist.Section,
Li = bogyconfiglist.LineItem,
CrossCalc1Q = confg == null ? string.Empty : (confg.CrossCalc1Q == null ? "" : confg.CrossCalc1Q.Replace("~9999", string.Empty).Trim()),
CrossCalc2Q = confg == null ? string.Empty : (confg.CrossCalc2Q == null ? "" : confg.CrossCalc2Q.Replace("~9999", string.Empty).Trim()),
CrossCalc3Q = confg == null ? string.Empty : (confg.CrossCalc3Q == null ? "" : confg.CrossCalc3Q.Replace("~9999", string.Empty).Trim()),
CrossCalc4Q = confg == null ? string.Empty : (confg.CrossCalc4Q == null ? "" : confg.CrossCalc4Q.Replace("~9999", string.Empty).Trim()),
CrossCalcFY = confg == null ? string.Empty : (confg.CrossCalcFY == null ? "" : confg.CrossCalcFY.Replace("~9999", string.Empty).Trim()),
AllowComma = confg == null ? false : confg.AllowComma,
AllowedDecimalPlace = confg == null ? string.Empty : confg.AllowedDecimalPlace,
AllowPercentageSign = confg == null ? false : confg.AllowPercentageSign,
CurrencySign = confg == null ? string.Empty : confg.CurrencySign,
IsQcCheck = confg == null ? false : confg.QCCheck,
QcType = confg == null ? string.Empty : confg.QCType,
FormulaLiConfig = confg == null ? string.Empty : (confg.StandrdFormula == null ? "" : confg.StandrdFormula.Replace("~9999", string.Empty).Trim()),
xFundCode = bogyconfiglist.xFundCode == null ? string.Empty : bogyconfiglist.xFundCode
}).Distinct().ToList<QCHelper>();
resultset stored into BogeyConfigList but i heard that List will have many empty items in it when data will be stored there and those empty item will consume memory.
so before join how could i declare List<T> with proper size as a result join result set can accommodate into List<T> ?
Please guide me how to handle this situation. i have like series of many joins in my routine where i am not able to mention List<T> size because i do not in advance how many data will be there after join in result set. discuss best approach to handle my scenario where i can save some memory. thanks