Note that there are some explanatory texts on larger screens.

plurals
  1. PONo generic method 'Sum' on type 'System.Linq.Enumerable' is compatible
    text
    copied!<p>I am having some issues with the MVC Wrappers for Kendo UI. It seems that IEnumerable does not support any aggregate values other than count. The exception that I get is: No generic method 'Sum' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.</p> <p>I am not sure how to get around this issues nor am I sure if it is a flaw with Kendo.</p> <p><strong>Please note that the aggregate function used below is not LINQ per say but what Kendo UI's wrapper provides as a function. Please see <a href="http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/configuration" rel="nofollow">Kendo UI Documentation</a> for more information.</strong></p> <p><strong>Data Source:</strong></p> <ul> <li>Northwind</li> </ul> <p><strong>Controller:</strong></p> <pre><code>public ActionResult Index() { return View(); } public ActionResult Read([DataSourceRequest] DataSourceRequest request) { return GetView(request); } private IEnumerable&lt;dynamic&gt; GetData() { var db = new NwEntities(); return db.Products; } private JsonResult GetView(DataSourceRequest request) { return Json(GetData().ToDataSourceResult(request)); } </code></pre> <p><strong>View:</strong></p> <pre><code>@model IEnumerable&lt;dynamic&gt; @( Html.Kendo().Grid(Model).Name("Grid") .DataSource(ds =&gt; ds.Ajax() .Model(m =&gt; { m.Id("ProductID"); m.Field("ProductName", typeof(string)); m.Field("UnitPrice", typeof(decimal)); }) .Aggregates(aggregate =&gt; aggregate.Add(a =&gt; "UnitPrice").Count().Sum()) .Read(r =&gt; r.Action("Read", "Home")) ) .Columns(columns =&gt; { columns.Bound("ProductID"); columns.Bound("ProductName"); columns.Bound("UnitPrice").Format("{0:c}"); }) .Groupable() ) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload