0
votes

I'm facing a problem with breeze metadata. I developed a system with breeze controller. I see my model in the metadata including all navigation properties. When I fetch the data from the server I see my objects filled with the expected field, but the deserialized object on client side only includes the simple field without the collection.

I see in the metadata and the returned object from the server like following:

 public partial class DesignType
    {      
        public DesignType()
        {        
            this.Product = new HashSet<Product>();
        }

        public int Id { get; set; }       
        public string Name { get; set; } 
        public string Code { get; set; }        

        public virtual ICollection<Product> Product { get; set; }
        public virtual VisionType Vision { get; set; }        
    }

public partial class VisionType
    {   

        public VisionType()
        {    

            this.DesignType = new HashSet<DesignType>();
        }

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

        public virtual ICollection<DesignType> DesignType { get; set; }
    }

Here is the query code :

var query = breeze.EntityQuery.from("Designs");
            breeze.manager.executeQuery(query).then(function (queryResult) {
                callback(queryResult.results)
            }).fail(function (queryFailed) {
                error(queryFailed);
            });

The results objects only contain the simple data properties and ignors the properties ICollection Product and Vision .

Any ideas. Thanks in advance...

1
Can you please post query, method in controller and C# model of Object A? Possibly definition of Object Y and B as well (at least important parts with ID and foreign key).Dominictus
Thanks for the reply , Please see the updated question.Wasim

1 Answers

1
votes

Your query only asks for the root type, DesignType, so that is all that should be returned. I'll assume that your server side method is not returning the related Product and Vision entities (which it could do but I'm betting that you're not making that happen).

So Breeze is doing what you asked.

If the client wants the related entities, it can ask for them with an expand clause:

breeze.EntityQuery.from("Designs")
      .expand('Products, Vision')

Check out the documentation on queries and expand

Update 11 Dec 2013

If I understand your comment, (a) you now understand why you don't see Product because you are neither requesting products on the client nor pushing them out from the server, (b) your web api is including the related Vision instance and (b) you are seeing Vision data in the JSON response from the query.

The remaining mystery is why someDesignType.Vision is returning null.

Please read "Query response debugging" focusing in particular on the reference navigation property and the foreign key property on Product that points back to the DesignType. If you're still mystified, please show us how the details of the Vision navigation property as explained there.