Telerik MVC 网格错误

发布于 2024-12-11 19:09:43 字数 1875 浏览 0 评论 0原文

编译器错误消息:CS1977:无法使用 lambda 表达式作为动态分派操作的参数,而不先将其转换为委托或表达式树类型

我在此项目中使用存储库模式,因此我通过服务调用检索的数据而不是常规的 linq 查询。我不确定他们将争论交给代表或专家是什么意思。树类型。这是代码。

 @(Html.Telerik().Grid(Model)
    .Name("Grid").Columns(columns =>
    {
        columns.Bound(o => o.formId).Width(100);
        columns.Bound(o => o.Name).Width(200);
        //columns.Bound(o => o.ShipAddress);
        //columns.Bound(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(120);
    })
    .DataBinding(dataBinding => 
    {
        dataBinding.Server().Select("Index", "Grid", new { ajax = ViewData["ajax"] });
        dataBinding.Ajax().Select("_Index", "Grid").Enabled((bool)ViewData["ajax"]);
    })
            .Scrollable(scrolling => scrolling.Enabled((bool)ViewData["scrolling"]))
            .Sortable(sorting => sorting.Enabled((bool)ViewData["sorting"]))
            .Pageable(paging => paging.Enabled((bool)ViewData["paging"]))
            .Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
            .Groupable(grouping => grouping.Enabled((bool)ViewData["grouping"]))
            .Footer((bool)ViewData["showFooter"])

public ActionResult Index(bool? ajax, bool? scrolling, bool? paging, bool? filtering, bool? sorting,
        bool? grouping, bool? showFooter)
    {
        ViewData["ajax"] = ajax ?? true;
        ViewData["scrolling"] = scrolling ?? true;
        ViewData["paging"] = paging ?? true;
        ViewData["filtering"] = filtering ?? true;
        ViewData["grouping"] = grouping ?? true;
        ViewData["sorting"] = sorting ?? true;
        ViewData["showFooter"] = showFooter ?? true;
        return View(formService.GetForms());
    }

    [GridAction]
    public ActionResult _Index()
    {
        return View(new GridModel(formService.GetForms()));
    }

Compiler Error Message: CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type

I am using the Respository pattern in this project, so the data i retrieved by way of service calls and not regular linq queries. I am unsure as to what they may mean by cast the arguement to a delegate or exp. tree type. here is the code.

 @(Html.Telerik().Grid(Model)
    .Name("Grid").Columns(columns =>
    {
        columns.Bound(o => o.formId).Width(100);
        columns.Bound(o => o.Name).Width(200);
        //columns.Bound(o => o.ShipAddress);
        //columns.Bound(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(120);
    })
    .DataBinding(dataBinding => 
    {
        dataBinding.Server().Select("Index", "Grid", new { ajax = ViewData["ajax"] });
        dataBinding.Ajax().Select("_Index", "Grid").Enabled((bool)ViewData["ajax"]);
    })
            .Scrollable(scrolling => scrolling.Enabled((bool)ViewData["scrolling"]))
            .Sortable(sorting => sorting.Enabled((bool)ViewData["sorting"]))
            .Pageable(paging => paging.Enabled((bool)ViewData["paging"]))
            .Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
            .Groupable(grouping => grouping.Enabled((bool)ViewData["grouping"]))
            .Footer((bool)ViewData["showFooter"])

)

public ActionResult Index(bool? ajax, bool? scrolling, bool? paging, bool? filtering, bool? sorting,
        bool? grouping, bool? showFooter)
    {
        ViewData["ajax"] = ajax ?? true;
        ViewData["scrolling"] = scrolling ?? true;
        ViewData["paging"] = paging ?? true;
        ViewData["filtering"] = filtering ?? true;
        ViewData["grouping"] = grouping ?? true;
        ViewData["sorting"] = sorting ?? true;
        ViewData["showFooter"] = showFooter ?? true;
        return View(formService.GetForms());
    }

    [GridAction]
    public ActionResult _Index()
    {
        return View(new GridModel(formService.GetForms()));
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

银河中√捞星星 2024-12-18 19:09:43

这是我的疏忽,视图的返回类型是 Viewmodel 的类型,而不是来自服务模型的模型。

It was negligence on my part, the return type of the view was of the type of the Viewmodel as opposed to the model coming in from the service model.

对你的占有欲 2024-12-18 19:09:43

你的模型中有一些动态的东西,不是吗?该错误表明 C# 无法从动态分派操作创建表达式。

如果要将 Telerik Grid for ASP.NET MVC 绑定到动态模型,请检查 代码库项目。

There is something dynamic in your model, isn't it. The error is telling that C# can't create an expression from a dynamically dispatched operation.

If you want to bind Telerik Grid for ASP.NET MVC to dynamic model check this code library project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文