【问题标题】:how to return results that have a date of yesterday and before如何返回具有昨天和之前日期的结果
【发布时间】:2014-06-25 01:30:35
【问题描述】:

我正在使用 LLBLGen 适配器模型返回结果。使用断点,因为我还不能让它们填充剑道网格,我可以看到它们都回来了。但是,我只需要返回具有昨天和之前日期属性的结果。我对剑道网格和 LLBL 适配器都不熟悉。大多数其他示例都使用实体框架。这是我到目前为止所拥有的。没有错误消息是因为我卡在如何设置过滤器上?

控制器

public ActionResult BundleStatus()
    {
        return View();

    }

    [HttpPost]
    public ActionResult BundleStatusRead([DataSourceRequest] DataSourceRequest request)
    {

            var span = DateTime.Today.AddDays(-1);
            DataAccessAdapter adapter = new DataAccessAdapter();
            EntityCollection allBundles = new EntityCollection(new CarrierBundleEntityFactory());
            adapter.FetchEntityCollection(allBundles, null);
           var results = allBundles;

         return Json(results.ToDataSourceResult(request));
    }

}

查看

@{
ViewBag.Title = "BundleStatusGet";
  }

 <div>
@(Html.Kendo().Grid<ZoomAudits.DAL.EntityClasses.CarrierBundleEntity>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(c => c.BundleId).Width(140);
        columns.Bound(c => c.CarrierId).Width(190);
        columns.Bound(c => c.Date);
        columns.Bound(c => c.IsSent).Width(110);
    })
    .HtmlAttributes(new { style = "height: 380px;" })
    .Scrollable()
    .Groupable()
    .Sortable()
    .Pageable(pageable => pageable
        .Refresh(true)
        .PageSizes(true)
        .ButtonCount(5))
                .Selectable(selectable => selectable
                .Mode(GridSelectionMode.Multiple)
                .Type(GridSelectionType.Cell))
            //.Events(events => events.Change("onChange").Sync("sync_handler")))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("BundleStatusRead", "BundleStatus"))
                //.Update(update => update.Action("EditingInline_Update", "Grid"))
    )
)

更新控制器

public ActionResult BundleStatusRead([DataSourceRequest] DataSourceRequest request)
    {

            var span = DateTime.Today.AddDays(-1);
            DataAccessAdapter adapter = new DataAccessAdapter();
            EntityCollection allBundles = new EntityCollection(new CarrierBundleEntityFactory());
            RelationPredicateBucket filter = new RelationPredicateBucket(CarrierBundleFields.Date == span);
            adapter.FetchEntityCollection(allBundles, filter);
           var results = allBundles;

         return Json(results.ToDataSourceResult(request));

它没有返回任何结果?这就是我在 var results LLBL Enumeration 处打开断点时看到的结果

【问题讨论】:

    标签: c# asp.net-mvc kendo-grid llblgenpro


    【解决方案1】:

    您好,我已经有一段时间没有使用 LLBLGen 了,那是在适配器之前。但是,我找到了有关使用 EntityCollection&lt;T&gt; 类,LLBLGen 适配器的 this 文档。希望对您有所帮助。

    对了,你也可以使用[HttpGet],设置动作结果为允许get。

    return Json(results.ToDataSourceResult(request)), JsonRequestBehavior.AllowGet);
    

    如果您想获取昨天和之前的信息,请使用:

    RelationPredicateBucket filter = new RelationPredicateBucket(CarrierBundleFields.Date <= span);
    

    【讨论】:

    • 它确实让我更进一步。我认为?查看我的编辑
    • 如果数据库中没有具有昨天日期的数据,这将是正确的响应。正确的?我如何设置它,让它昨天和之前的样子?
    • 用可能的解决方案更新答案。
    • 非常感谢!现在我需要处理填充网格
    • 你能看看我的循环引用问题吗? stackoverflow.com/questions/24399548/…
    猜你喜欢
    • 2014-04-20
    • 2012-12-29
    • 1970-01-01
    • 2012-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多