Breeze newValue.getProperty is not a function

自古美人都是妖i 提交于 2019-12-13 16:09:43

问题


I've updated to new version of breeze and ef 6. And after I did this, I get error

newValue.getProperty is not a function

Whenever I try to execute expand query. (for "normal" queries everything is fine )

So here is my model for Mucsle:

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

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

And for MuscleGroup:

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

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

Here is my DtabaseContext Configuration:

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

And I try to fetch data like this:

Function in dataService:

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;
            }
        }

Call of function:

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

    };

With older version of breeze and EF5 this works, so I wonder what am I doing wrong ?

EDIT

I believe, I've found what causes problem, when I enter in url:

breeze/Service/Muscles?$expand=MuscleGroup

With "old" (older version of breeze, and EF 5) settings, output is this:

[{"$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},

And with EF 6 and latest version of 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}]

So difference is in $type, and in "new" output, even tough, in database I have only two entries, I got 4 items.


回答1:


Solved it !

So the problem was here:

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

When I removed this line:

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

It worked like a charm,

Jay thanks for all the help :)



来源:https://stackoverflow.com/questions/20360417/breeze-newvalue-getproperty-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!