I am kind of stuck again as I am unable to understand this.
So I have a class named CSVItem
:
public class CSVItem
{
public int SortedAccountNumber { get; set; }
public DateTime Date { get; set; }
public int SNO { get; set; }
public string AccountNumber { get; set; }
public double Value { get; set; }
public int Year
{
get
{
if (Date.Month > MainWindow.fiscalMonth)
{
return Date.Year+1;
}
return Date.Year;
}
}
public int StaticCounter { get { return 1; } }
public CSVItem(string accNo, DateTime date, double value, int sNo)
{
Value = value;
Date = date;
AccountNumber = accNo;
SNO = sNo;
}
}
I read a CSV, and I make a List of Type CSV Item with about 500k items. Then I try to sort using the default Order By method of the list, and try to return the list from the sorted collection. Here is the code:
List<CSVItem> items = new List<CSVItem>();
// ---- some code to read csv and load into items collection
List<CSVItem> vItems = items.OrderBy(r1 => r1.AccountNumber).ThenBy(r1 => r1.Date).ToList();
It is like taking forever to sort and then convert the collection back to a list. Well I have certainly tried loading about a million records previously and never had such -no response- from Linq Sorting ever and it is kind of driving me crazy. Any help or suggestion on where I can look for finding the problem?