0

I have two clases in relation one-many:

public class ClasssA
  {
    public int Id { get; set; }

    public int ClassBId { get; set; }

    public virtual ClassB ClassB { get; set; }
  }

  public class ClassB
  {
    public int Id { get; set; }

    public string Example { get; set; }

    public virtual ICollection<ClassA> ClassACollection { get; set; }
  }

when I execute query:

var query = EntityQuery.from('ClassB');

I get exception: "Collection navigation properties may NOT be set" in q.js during map to entity property 'ClassACollection'. How to execute query properly?

Mariusz
  • 442
  • 5
  • 16

1 Answers1

0

I don't think that your problem has to do with how you are querying, I think it has to do with something else in your code. The exception seems fairly straight forward - are you trying to pass a value into your collection property?

You are probably trying to use Knockout's setter to set the value of a navigation property like such somewhere in your code -

ClassAObservable.ClassACollection(data.results);

Where you are meaning to push each object like so -

ClassAObservable.ClassACollection.push(result);

And a better option for you is to properly map your ClassA results back to ClassB entities so you don't have to explicitly do this. Without seeing where you are doing this it is hard to determine which method to take.

PW Kad
  • 14,953
  • 7
  • 49
  • 82