gpt4 book ai didi

javascript - Breeze newValue.getProperty 不是函数

转载 作者:行者123 更新时间:2023-11-29 22:07:06 25 4
gpt4 key购买 nike

我已经更新到新版本的 breeze 和 ef 6。在我这样做之后,我得到了错误

newValue.getProperty is not a function

每当我尝试执行扩展查询时。 (对于“正常”查询一切都很好)

这是我的 Mucsle 模型:

    public int MuscleId { get; set; }
public string Name { get; set; }

public int MuscleGroupId { get; set; }
public MuscleGroup MuscleGroup { get; set; }

对于肌肉群:

    public int MuscleGroupId { get; set; }
public string Name { get; set; }

public ICollection<Muscle> Muscles { get; set; }

这是我的 DtabaseContext 配置:

public WebDatabaseContext()
: base("DefaultConnection")
{
Configuration.LazyLoadingEnabled = false;
Configuration.ProxyCreationEnabled = false;
}

我尝试像这样获取数据:

数据服务中的函数:

getAllIncluding: function(controllerAction, including) {
var query = breeze.EntityQuery.from(controllerAction).expand(including);
return manager.executeQuery(query).then(querySucceeded).fail(getFailed);

function querySucceeded(data) {
items = data.results;
return data.results;
}
}

函数调用:

$scope.getAllMuscles = function() {
adminCrudService.getAllIncluding("Muscles", "MuscleGroup")
.then(querySucceeded)
.fail(queryFailed);

};

对于较旧版本的 breeze 和 EF5,这是有效的,所以我想知道我做错了什么?

编辑

我相信,当我输入 url 时,我已经找到了导致问题的原因:

breeze/Service/Muscles?$expand=MuscleGroup

使用“旧”(旧版本的 breeze 和 EF 5)设置,输出是这样的:

[{"$id":"1","$type":"Test.Domain.Model.MuscleGroupAggregate.Muscle, Test.Domain.Model","MuscleId":1,"Name":"Biceps","NameInLatin":"","ImageUrl":null,"MuscleGroupId":1,"MuscleGroup":null},

{"$id":"2","$type":"Test.Domain.Model.MuscleGroupAggregate.Muscle, Test.Domain.Model","MuscleId":3,"Name":"Triceps","NameInLatin":"","ImageUrl":null,"MuscleGroupId":1,"MuscleGroup":null},

使用 EF 6 和最新版本的 breeze:

    [{"$id":"1","$type":"System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib","MuscleGroup":

{"$id":"2","$type":"System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib","MuscleGroupId":1,"Name":"TestMuscleG1","Description":"","ImageUrl":null},"MuscleId":1,"Name":"Test2","NameInLatin":"","ImageUrl":null,"MuscleGroupId":1},

{"$id":"3","$type":"System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib","MuscleGroup":

{"$id":"4","$type":"System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib","MuscleGroupId":1,"Name":"TestMuscleG1","Description":"","ImageUrl":null},"MuscleId":2,"Name":"32r23r","NameInLatin":"","ImageUrl":null,"MuscleGroupId":1}]

所以区别在于 $type 和"new"输出,甚至很难,在数据库中我只有两个条目,我有 4 个项目。

最佳答案

解决了!

所以问题出在这里:

[HttpGet]
[Queryable(AllowedQueryOptions = AllowedQueryOptions.Supported | AllowedQueryOptions.Expand)]
public IQueryable<Muscle> Muscles()
{
return _contextProvider.Context.Muscles;
}

当我删除这一行时:

  [Queryable(AllowedQueryOptions = AllowedQueryOptions.Supported | AllowedQueryOptions.Expand)]

它就像一个魅力,

杰感谢所有的帮助:)

关于javascript - Breeze newValue.getProperty 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20360417/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com