Why isn't the below code working? I am getting an error.
It says 'Cannot implicitly convert type 'V' to int ' .
private ObservableCollection<DataItem> method<T, V>(DataTable dt, SeriesItem seriesItem, FilterValues filter, ObservableCollection<DataItem> chart)
{
var result = from t in dt.AsEnumerable()
group t by new { type = t.Field<T>(seriesItem.LabelMapping).ToString().ToUpper() } into g
orderby g.Key.type
select new
{
Item_Type = g.Key.type.ToString(),
Amount = seriesItem.IsSum ? g.Sum(s => s.Field<V>(seriesItem.ValueMapping)) : g.Count()
};
foreach (var g in result)
{ chart.Add(new DataItem(g.Item_Type, double.Parse(g.Amount.ToString()))
{ IsSum = seriesItem.IsSum, IsDisplayCurrency = seriesItem.IsDisplayCurrency }); }
return chart;
}