levitatejay
levitatejay

Reputation: 1278

Entity property goes missing between server response and QuerySucceeded

Entity property 'Devices' goes missing from my account entity between the server's JSON response and QuerySucceeded callback

When I check my JSON I can see the array of devices on my returned account object. When I put a breakpoint in my QuerySucceeded method the data.response Account object has no 'Devices' property.

Some extra information:

Here is the relevant part in AccountMap.cs:

this.HasMany(t => t.Devices)
                .WithMany(t => t.Accounts)
                .Map(m =>
                    {
                        m.ToTable("DeviceAccounts");
                        m.MapLeftKey("Account_Id");
                        m.MapRightKey("Device_Id");
                    });

Relevant parts from Account.cs:

public Account()
        {
            this.Devices = new List<Device>();
        }
public virtual ICollection<Device> Devices { get; set; }

and finally my query:

var query = entityQuery.from('Accounts')
                .where('id', 'eq', id)
                .expand('devices')
                .orderBy('givenName, familyName');

enter image description here

Any ideas for what could be causing this?

Upvotes: 3

Views: 171

Answers (1)

levitatejay
levitatejay

Reputation: 1278

Many to many relationships aren't supported in Breeze unless you expose the join table.

Found the answer here: Many-to-many relations in Breeze

There is also an ongoing suggestion to support this in Breeze here: https://breezejs.uservoice.com/forums/173093-breeze-feature-suggestions/suggestions/3317477-many-many-relationship-for-ef

To get an observableArray of devices from an Account I have to make a for loop to go through each item in Account.DeviceAccounts and push the internal Device to an observableArray.

Upvotes: 1

Related Questions