This question is locked. New answers and comments are not allowed.
I have a simple grid set up to server bind to a collection of OpenAccess Entities:
Controller:
Controller:
publicActionResult Index(){var SmContext =newSmDataEntities.EntitiesModel();returnView(SmContext.Smdetails);}
View:@model IEnumerable<SmDataEntities.Smdetail>@{ViewBag.Title = "Index";}<h2>Index</h2>@(Html.Telerik().Grid(Model).Name("Grid").Columns(columns =>{columns.Bound(o => o.Amt).Aggregate(aggregates => aggregates.Count()).FooterTemplate(@<text>Total Count: @item.Count</text>).GroupFooterTemplate(@<text>Count: @item.Count</text>);}).Sortable().Pageable().Groupable())
Without the aggregate added to the column, the grid works perfectly. With the aggregate it produces this error:[NotSupportedException: Execution of 'System.Linq.Queryable:Where(IQueryable`1,Expression`1)' on the database server side currently not implemented.]Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQueryImpl(Type type, Int32 elementAt, Object[] groupResolutionParamValues, Boolean single) +611Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQuery(Type type, Int32 elementAt, Object[] groupResolutionParamValues, Boolean single) +50[NotSupportedException: An exception occured during the execution of 'Extent<SmDataEntities.Smdetail>.GroupBy(item => 1).OrderBy(group53499056 => group53499056.Key).Select(group53499056 => new AggregateFunctionsGroup() {Key = Convert(group53499056.Key), ItemCount = group53499056.Count(), HasSubgroups = False, AggregateFunctionsProjection = new DynamicClass1() {Count_Amt_63942930 = Extent<SmDataEntities.Smdetail>.Where(item => (1 == group53499056.Key)).Count()}, Items = group53499056})'. See InnerException for more details.]Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQuery(Type type, Int32 elementAt, Object[] groupResolutionParamValues, Boolean single) +195Telerik.OpenAccess.Query.ExpressionExecution.PerformDatabaseQuery(Piece`1 piece, Object[] grpVals) +400Telerik.OpenAccess.Query.Piece`1.System.Collections.IEnumerable.GetEnumerator() +37Telerik.Web.Mvc.Extensions.QueryableExtensions.Aggregate(IQueryable source, IEnumerable`1 aggregateFunctions) +197Telerik.Web.Mvc.UI.GridDataProcessor.CalculateAggregates() +152Telerik.Web.Mvc.UI.Grid`1.CreateRenderingData() +1339Telerik.Web.Mvc.UI.Grid`1.WriteHtml(HtmlTextWriter writer) +584Telerik.Web.Mvc.UI.ViewComponentBase.ToHtmlString() +86Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.ToHtmlString() +22Telerik.Web.Mvc.{Dynamic}.GridBuilder`1[[SmDataEntities.Smdetail, SmDataEntities, Version=1.0.0.0\, Culture=neutral\, PublicKeyToken=null\]\].IHtmlString.ToHtmlString() +5System.Web.HttpUtility.HtmlEncode(Object value) +38System.Web.WebPages.WebPageBase.Write(Object value) +64ASP._Page_Views_Aggregate_Index_cshtml.Execute() in c:\Work\Solberg\SmQueryMVC\SmQueryMVC\Views\Aggregate\Index.cshtml:7System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81System.Web.WebPages.StartPage.RunPage() +19System.Web.WebPages.StartPage.ExecutePageHierarchy() +65System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115Glimpse.Net.Plumbing.GlimpseView.Render(ViewContext viewContext, TextWriter writer) +30System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +303Castle.Proxies.ControllerActionInvokerProxy.InvokeActionResult_callback(ControllerContext controllerContext, ActionResult actionResult) +13Castle.Proxies.Invocations.ControllerActionInvoker_InvokeActionResult.InvokeMethodOnTarget() +121Castle.DynamicProxy.AbstractInvocation.Proceed() +134Glimpse.Net.Interceptor.InvokeActionResultInterceptor.Intercept(IInvocation invocation) +335Castle.DynamicProxy.AbstractInvocation.Proceed() +534Castle.Proxies.ControllerActionInvokerProxy.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +126System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343System.Web.Mvc.Controller.ExecuteCore() +116System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8892525System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
If I force the controller to return the collection as a list, SmContext.Smdetails.ToList(), everything
works fine. This approach, however, has major performance implications. Is there anyway to do aggregates
without eager loading collections from OpenAccess?
This brings me to my next question. I have another grid that I am loading an OA entity as an IEnumerable,
but because of a relationship, it's causing a circular reference error. I've read the blogs and forums
about ways to get around this error, but I need the relationship defined and I take the performance hit if
I load into a custom viewmodel. I've even tried to alter the T4 templates to generate the [ScriptIgnore]
attribute for the property, but it didn't work. Is there anyway you can think of to have the js serializer
ignore this property?
Thanks in advance, and great job on the controls so far!