Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc BreezeJS自定义类型映射不正确_Asp.net Mvc_Breeze - Fatal编程技术网

Asp.net mvc BreezeJS自定义类型映射不正确

Asp.net mvc BreezeJS自定义类型映射不正确,asp.net-mvc,breeze,Asp.net Mvc,Breeze,这对我来说有点神秘。 我在客户端上定义了一个自定义类型,如下所示: var store = manager.metadataStore; store.addEntityType({ shortName: "ItemContainer", autoGeneratedKeyType: AutoGeneratedKeyType.Identity, dataProperties: { id: { da

这对我来说有点神秘。 我在客户端上定义了一个自定义类型,如下所示:

var store = manager.metadataStore;
store.addEntityType({
            shortName: "ItemContainer",
            autoGeneratedKeyType: AutoGeneratedKeyType.Identity,
            dataProperties: {
                id: { dataType: DataType.Int32, isNullable: false, isPartOfKey: true },
                type: { dataType: DataType.Int32, isNullable: false },
                isViewed: { dataType: DataType.Boolean, isNullable: false },
                itemCount: { dataType: DataType.Int32, isNullable: false }
            }
        });

store.setEntityTypeForResourceName('Container', 'ItemContainer');
这是作为匿名类型(Fiddler)从服务器传递的内容:

g.Count()(LINQ计数方法)似乎是罪魁祸首。如果我传递一个普通整数,它就可以正常工作。也许这个函数得到了延迟计算,而breeze没有在正确的时间得到值


谢谢

服务器端投影代码是什么样子的?我添加了服务器代码。我通过发送JSON并在客户机上解析它(删除了客户机上的自定义实体类型),暂时解决了这个问题。但我仍然很好奇为什么这不起作用。对不起,无法重新编程。。。
[{"$id":"1","$type":"<>f__AnonymousType1`4[[System.Int32,mscorlib],
[System.Int32, mscorlib],
[System.Boolean, mscorlib],
[System.Int32, mscorlib]], XYZ",
"Id":43,"Type":1,"IsViewed":true,"ItemCount":19}]
var c = Items.GroupBy(x => new { x.Item.ItemTypeID, x.IsViewed })
                .Select(g => new { Id = ID, Type = g.Key.ItemTypeID, IsViewed = g.Key.IsViewed, ItemCount = g.Count() });