【问题标题】:Breeze inlineCount is undefinedBreeze inlineCount 未定义
【发布时间】:2014-02-28 20:04:03
【问题描述】:

我正在查询:

var query = entityQuery.from('Items').where(fullPredicate).orderBy(sortingColumn + ' ' + ordering).skip(numOfEntities * (pageNum - 1)).take(numOfEntities).inlineCount();

return manager.executeQuery(query)
                .then(querySucceeded)
                .fail(queryFailed);

控制器如下所示:

[Queryable(AllowedQueryOptions = AllowedQueryOptions.All,
                    AllowedFunctions = AllowedFunctions.AllFunctions,
                    MaxNodeCount = 10000)]
        [HttpGet]
        public IQueryable<Item> Items()
        {
            return _contextProvider.Context.Items.Include("A").Include("B").Include("C");
        }

响应是纯 JSON,包含所有项目和链接(包括)项目(A、B 和 C),但没有 inlineCount。在 querySucceeded 中读取数据时,有一个名为 inlineCount 的参数,但设置为 undefined。

我尝试将以下内容添加到 web.config,但没有帮助。

<httpProtocol>
  <customHeaders>
    <add name="Access-Control-Allow-Origin" value="*" />
    <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
    <add name="Access-Control-Allow-Methods" value="GET,POST,OPTIONS" />
    <add name="Access-Control-Expose-Headers" value="X-InlineCount" />
  </customHeaders>
</httpProtocol>

也从 1.4.0 升级到 1.4.2,但没有帮助。

【问题讨论】:

    标签: breeze


    【解决方案1】:

    我终于让我的服务器使用 Breeze.js 客户端和 Breeze Web Api 服务器控件 (BreezeController) 以正确的 inlinecount 值响应。

    您需要添加属性 BreezeQueryable 而不是标准的 OData Queryableinlinecount 不会包含在 Breeze 控制器的服务器响应中,除非您在方法上方包含此属性。

    所以下面的服务器代码解决了我的问题:

    [HttpGet, BreezeQueryable]
    public IQueryable<FinDataModelsPublic.InvoicesView> InvoicesView(ODataQueryOptions<FinDataModelsPublic.InvoicesView> options, int custId)
    {
        return FBll.InvoicesView(custId);
    }
    

    Bll.InvoicesView 上方是我的数据模型中返回 IQueryable 结果的方法。
    希望这会有所帮助

    【讨论】:

      【解决方案2】:

      删除以下解决了问题。可能存在一个错误,即 inlineCount 未包含在 AllFunctions 或其他内容中。

      [Queryable(AllowedQueryOptions = AllowedQueryOptions.All,
          AllowedFunctions = AllowedFunctions.AllFunctions,
          MaxNodeCount = 10000)]
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-09-23
        • 1970-01-01
        • 2013-02-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-28
        • 1970-01-01
        相关资源
        最近更新 更多