Breeze无法自动获取元数据 [英] Breeze not getting metadata automatically

查看:133
本文介绍了Breeze无法自动获取元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Breeze文档说:



这个[MetadataStore.FetchMetadata]调用是在Breeze尝试执行针对远程服务的第一次查询之前自动进行的

This [MetadataStore.FetchMetadata] call is made automatically by Breeze just before it attempts to perform it's first query against a remote service


但是我打这样的电话:

function getBags() {

    var bags;
    var query = breeze.EntityQuery.from('Bags');

    return manager.executeQuery(query).then(querySucceded, _queryFailed);

    function querySucceded(data) {
        bags = data.result;
        logSuccess("Retrieved Bag Data")
        return bags;
    }
}

function _queryFailed(error) {
    logError(config.appErrorPrefix + "Query Failed: " + error.message);
    throw error;
}

当我这样做时,我收到此错误:

When I do this I get this error:


无法通过名称找到'Type':'Bag:#DataAccess'。请务必先执行查询或调用fetchMetadata。

"Unable to locate a 'Type' by the name: 'Bag:#DataAccess'. Be sure to execute a query or call fetchMetadata first."

_queryFailed error.message 的值c $ c>。

as the value of error.message in _queryFailed.

注意:我知道它连接到我的OData服务,因为如果我为查询添加了随机内容,我会找到一个未找到的资源:

NOTE: I know it is connecting to my OData service, because if I put in random stuff for my query I get a resource not found:


找不到'Bagsasdfas'段的资源。;

Resource not found for the segment 'Bagsasdfas'.;

我正在使用HotTowel.Angular和HotTowel.Angular.Breeze nuget包。唯一的区别是我直接连接到WCF数据服务(OData)。

I am using the HotTowel.Angular and HotTowel.Angular.Breeze nuget packages. The only difference is that I am connecting directly to a WCF Data Service (OData).

在调用查询之前我确实有这些调用:

I do have these calls before I call the query:

breeze.config.initializeAdapterInstances({ dataService: "OData" });
breeze.config.initializeAdapterInstance("modelLibrary", "backingStore", true);

任何人都知道为什么Breeze不会为此自动获取元数据?

推荐答案

我找到了解决此问题的方法。 Breeze正在获取元数据。

I found the fix for this issue. Breeze is getting the metadata.

但Breeze有一个大部分未记录的OData要求,不属于OData规范的一部分:

But Breeze has one mostly undocumented OData Requirement that is not part of the OData spec:

在元数据中,架构命名空间(位于元数据顶部)和 EntitySet EntityType命名空间(位于 EntityContainer )必须相同。

In the metadata the Schema Namespace (found toward the top of the metadata) and the EntitySet EntityType namespace (found under EntityContainer) must be the same.

感谢Brian Noyes的Pluralsight课程让我知道这个。

Thanks to the Pluralsight course by Brian Noyes for letting me know this.

注意:这适用于OData的WCF数据服务版本。对于Web API OData,您的里程可能会有所不同。

通过使包含我的Entity Framework模型的项目具有相同的名称,我能够实现这一目标。 namespace作为模型的(edmx)命名空间。

I was able to get this working by making the project that held my Entity Framework model have the same name and namespace as the model's (edmx) namespace.

您可以通过右键单击设计器并选择属性(命名空间是其中一个属性)来设置edmx的命名空间。

You can set the namespace of the edmx via right clicking in the designer and selecting properties (namespace is one of the properties).

一旦我将项目(及其中的所有文件)从名称DataAccess更改为我的edmx名称空间名称,Breeze就开始正常工作了。

Once I changed my project (and all the files in it) from the name "DataAccess" to the name of my edmx namespace Breeze started working just fine.

这篇关于Breeze无法自动获取元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆