BreezeJS:在MetadataStore更改枚举的文本值 [英] BreezeJS: Change Enum Text Values in MetadataStore

查看:113
本文介绍了BreezeJS:在MetadataStore更改枚举的文本值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我绝对爱BreezeJS真是太惊讶地看到,我的枚举值显示为它们的文本值,而不是他们的顺序的!我很想能够做的是,在客户端,打开MetadataStore,获取枚举和修改它的文本属性显示。

I'm absolutely loving BreezeJS and was so surprised to see that my Enum values were being displayed as their text values and not their ordinal ones! What I would love to be able to do is, on the client side, open the MetadataStore, fetch the enumeration and modify it's textual properties for display purposes.

这是目前可能?从我的研究它似乎没有,但我不知道是否有可能是一个简单的解决方法。我试过的一切都涉及到大量的黑客和服务器端的属性,但无济于事,或解决方案只是似乎过于复杂和不值得的好处。

Is this currently possible? From my research it would appear not, but I'm wondering if there is perhaps a simple workaround. Everything I've tried has involved a large number of hacks and server-side attributes, but to no avail, or the solution just seemed overly complex and not worth the benefits.

推荐答案

下面就是我说的关于如何获得<一个从原材料的元数据枚举值href=\"http://stackoverflow.com/questions/23979265/breeze-local-query-for-enumtype/24004166#24004166\">another SO评论。

Here is what I said about how to get the enum values from raw metadata in another SO comment.

的枚举值在由EF生成并发送到微风客户元数据可用。我同意微风应该自动接他们,并把他们的地方,所以你不必进行单独的请求,他们或从传递给MetadataStore.fetchMetadata成功回调原始的元数据提取它们。这是我们的积压。

The enum values are available in the metadata generated by EF and sent to a Breeze client. I agree Breeze should pick them up automatically and put them somewhere so you don't have to make a separate request for them or extract them from the raw metadata passed to the MetadataStore.fetchMetadata success callback. It's on our backlog.

同时,你必须手动得到它们。有一个<一href=\"https://github.com/Breeze/breeze.js.samples/blob/master/net/Doc$c$c/Doc$c$c/tests/metadataTests.js\"相对=nofollow>文件code测试展示了如何:

Meanwhile, you'll have to get them by hand. There is a DocCode test that shows how:

/*********************************************************
* Can can get enum types from raw EF-generated metadata
* Related to feature request #2271: Extract enum values from server metadata
*************************************************************/
asyncTest("can get enum type from raw EF-generated metadata", function() {

    var serviceName = testFns.foosMetadataServiceName;
    var store = new breeze.MetadataStore();
    store.fetchMetadata(serviceName)
        .then(metaSuccess, metaFail).fail(handleFail).fin(start);

    function metaSuccess(rawMetadata) {
        ok(true, "foos metadata fetched");
        var enumType = rawMetadata.schema && rawMetadata.schema.enumType;
        if (enumType && enumType.name ==='Color') {
            var members = enumType.member;
            ok(members.length,
                "should have several members; members are: " + JSON.stringify(members));
        } else {
            ok(false, "metadata should have had one enumType, 'Color'.");
        }
    }

    function metaFail(error) {
        ok(false, "foos metadata fetch failed: " + error.message);
    }

});

这篇关于BreezeJS:在MetadataStore更改枚举的文本值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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