As Dave said, that's a heck of a lot of logic to be performing within a loop that potentially has 1m records. It's absolutely no surprise to anybody that that would be running slow. There's even some logic that I don't understand the purpose of, like:
DataTable dtvdSales = ConvertListToDataTable<SalesDetails>(vdSalesList);
I mean, why create a
when you already have a list you can iterate over? But in any case, if I were you I'd look into how much of the logic of this code can be done natively within your SQL database via something like a stored procedure or function. Having the code execute directly within the database is likely to provide some improvement, but I imagine it'll still take a good while to complete. At the very least moving this logic out
of the C# code should help you identify logic that can either be trimmed or optimised.