I'm trying to subtotal a list, whereby certain columns need to be summed or averaged while others are not relevant for subtotalling e.g. the stock names.

I'm getting an error 

> 
> "The best overloaded method match for 
>  'System.Collections.Generic.List.Add(AnonymousType#1)'
>  has some invalid arguments Argument '1': cannot convert from
>  'AnonymousType#2' to 'AnonymousType#1'"
> 
> 
> 

when running this in Sage 200 Query Builder and can't see what I'm doing wrong. 

If I try it in Linqpad it tells me "The name 'cxt' does not exist in the current context"

Any ideas? Thanks!

---

```
var q = from d in cxt.K3_StockProfitMarginByCustomers
select new
{
    d.CustomerAccountName,
    d.CustomerAccountNumber,
    d.Code,
    d.Name,
    d.Profit,
    d.QuantitySold,
    d.TotalCost,
    d.TotalRevenue,
    d.MARGIN,
    d.SLCustomerAccountID,
    d.SOPOrderReturnID,
    d.SOPOrderReturnLineID
};

q = q.Distinct();

var l = q.ToList();
var summary = new 
{ 
   CustomerAccountName = "",
   CustomerAccountNumber = "",
   Code = "",
   Name = "", 
   Profit = (Decimal)q.Sum(o => o.Profit),
   QuantitySold = (Decimal)q.Sum(o => o.QuantitySold),
   TotalCost= (Decimal)q.Sum(o => o.TotalCost),
   TotalRevenue= (Decimal)q.Sum(o => o.TotalRevenue),
   MARGIN = (Decimal)q.Average(o => o.MARGIN),
   SLCustomerAccountID=(String)"",
   SOPOrderReturnID=(String)"",
   SOPOrderReturnLineID=(String)""
};

l.Add(summary);

return l.AsQueryable();

```