When To Add Extend Additional Complex Types Onto A Breeze Entity
Solution 1:
Providing that your relationships are not unidirectional, Breeze entities will automatically hook themselves together when you query them. ( Edit: as of v 1.3.5 - breeze will also hook up unidirectional relations as well. )
This means that if you use a query to extract n entities that just happen to be related all of them will be automatically linked to one another in the correct fashion. The same occurs if you use the EntityQuery.expand method. So your issue is simply how to query for whatever portion of the graph you want in the least number of calls.
Note: you should also look at the EntityAspect.loadNavigationProperty method if you really want to actually "walk" the graph. But this can be non-performant if you are dealing with large graphs.
Solution 2:
I have the same issue with Breezejs (1.4.2) q (0.9.7) I want to add a computed property for an entity.
var doctorInitializer = function (doctor) {
doctor.FullName = ko.computed(function () {
return doctor.FirstName() + " " + doctor.MiddleName() + " " + doctor.LastName() + " " + doctor.SurName();
});
};
var doctorName = '/breeze/polyclinic',
doctorManager = new breeze.EntityManager(doctorName);
var store = doctorManager.metadataStore;
store.registerEntityTypeCtor("Doctor", null, doctorInitializer);
i try adding a knockout computed to the constructor
var doctor = function() {
self.FullName = ko.computed( {
read: function() {
returnself.FirstName + " " + self.MiddleName + " " + self.LastName + " " + self.SurName;
},
deferEvaluation: true
});
};
store.registerEntityTypeCtor("Doctor", doctorInitializer);
in both cases only work if i remove the parenthesis but MiddleName and SurName is not required and instead of empty string i got null
this is the error i have http://screencast.com/t/bP9Xnmf9Jm
Post a Comment for "When To Add Extend Additional Complex Types Onto A Breeze Entity"