这是我的代码,我正在执行一个SQL查询,该查询返回超过50万行,然后,我将数据填充到列表中,以使用此数据进行很多linq查询。
是否有更好的解决方案来处理数据表并将数据填充到列表中?
Logger.Info("Executing sql query finished. Succesfully collected {0} requests.", requestTable.Rows.Count);
foreach (DataRow row in requestTable.Rows)
{
string receiveDateString = row["RequestReceiveDate"].ToString();
DateTime receiveDate = default(DateTime);
if (!string.IsNullOrWhiteSpace(receiveDateString))
{
receiveDate = Convert.ToDateTime(receiveDateString);
}
string validationDateString = row["RequestValidationDate"].ToString();
DateTime validationDate = default(DateTime);
if (!string.IsNullOrWhiteSpace(validationDateString))
{
validationDate = Convert.ToDateTime(validationDateString);
}
string addresseeNumberString = row["RequestAddresseNumber"].ToString();
int addresseNumber = default(int);
if (!string.IsNullOrWhiteSpace(addresseeNumberString))
{
addresseNumber = Convert.ToInt32(addresseeNumberString);
}
handledTodayRequests.Add(new Request(row["RequestNumber"].ToString(), Convert.ToInt32(row["RequestStatus"].ToString()), Convert.ToDateTime(row["RequestDoneDate"].ToString()), Convert.ToDateTime(row["RequestCreationDate"].ToString()), receiveDate, validationDate, Convert.ToDateTime(row["RequestDateDue"].ToString()), row["RequestSupplierComments"].ToString(),
addresseNumber, row["RequestReference"].ToString(), row["RequsetAddresseeType"].ToString(), row["ClaimNumber"].ToString(), Convert.ToInt32(row["ClaimSchemeNumber"].ToString()), row["ClaimSchemeName"].ToString()));
}