Beat Practice, use the result of SQL Linq as List and get the sums from it, or just use SQL Linq and use a new query
-
So I wrote this SQL Linq that grabs the cart items, which has all the info I need. To keep my functions clean and reusable,I thought maybe I should just standardize Sub Totals and make a class of it it, and add it to each model that requires it, and call the function to populate the values. Just to get an idea of what I'm talking about. I just made the code up below for clarity.
public class cartitems
{
public int cartID { get; set; }
public decimal totalPrice { get; set; }
public model_subTotals st { get; set; }
}public class model_subTotals
{
public decimal subTotal { get; set; }
}It is good practice for me to populate the first model, and then go back and send the results back into another function as a list to populate the 2nd model? I would be sending the first model back as a list, but I'm not sure if I can work sums on a list or not, never done it before. Or if I should just make a new query, and attach the result to the list.