2014-06-25 47 views
0

我使用LLBLGen适配器模型返回结果。使用断点是因为我无法让他们填充剑道网格,我可以看到他们都回来了。不过,我只需要返回具有昨天和之前日期属性的结果。我并不熟悉使用kendo网格和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结果LLBL的断点枚举没有结果

回答

0

嗨我没有在一段时间内使用LLBLGen,并且在适配器之前。但是,我发现this文档使用EntityCollection<T>类,LLBLGen适配器。希望能帮助到你。

顺便说一下,您还可以使用[HttpGet]并设置操作结果以允许获取。

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

如果你试图让昨天和以前的再使用:

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

它确实让我进了一步。我认为?看看我的编辑 – user3750212

+0

如果没有数据库中的数据与昨天的日期,这将是正确的回应。正确?我如何设置它,以便它在昨天和之前? – user3750212

+0

用可能的解决方案更新答案。 –

相关问题