Is something like the below possible?
public static T Sum<T>(this DataTable dt, string columnName)
where T : IEnumerable<decimal>, IComparable<decimal>
{
return (from c in dt.AsEnumerable()
where !c.IsNull(columnName)
select c.Field<T>(columnName)
).Sum();
}
It feels like i'm almost there, but not quite :/
Just trying to sum up either decimal or int values in a column in datatable. Currently getting a compile error, however think this is due to the incorrect generic constraint.