So I'm trying to have a list of profits in each month from my database. I want to do this in loop, I thnik it will be the best soulution.
Here we have a loop, that I want to count a profit for each month.
        using (var context = new ModelContext("ConnectionStringDbMagazynier"))
        {
            for (int i = 0; i < 12; i++)
            {
                decimal q = (from ar in context.Archives
                             where ar.SalesDate <= DateTime.Now.AddYears(-1).AddMonths(i + 1) && ar.SalesDate >= DateTime.Now.AddYears(-1).AddMonths(i)
                             let sum = context.Archiwum.Sum(x => x.Price)
                             select sum);
                profits[i] = decimal.ToDouble(q);
            }
        }
from this query i get an error:
Error   2   Cannot implicitly convert type 'System.Linq.IQueryable<decimal>' to 'decimal'   
My question is, how to make it witohut error? and is this solution ok? What in case, that i didn't sell anything in partiuclar month and the sum is null?