Reputation: 1196
I'm following Breeze's NoDb sample in order to add custom types to the Breeze metaDataStore. My goal is to be able to call my web api controller method and have a client-side version of that object fully hydrated.
I've been unable to retrieve an Employee object and map my Employee properties (FirstName, LastName) nor the complex types that I've included. These complex types are simply properties on my Employee object consisting of collections of other custom classes on the server side.
For example, I have a custom type of "CompanyAffiliates" that contains a CompanyId and a Name property.
I can't seem to get Breeze to map anything correctly, and I'm not getting any feedback from errors. Can anyone provide me with some suggestions?
Here's some relevant code:
addEmployeeType = function() {
var entityType = new _entityType({
shortName: "Employee",
namespace: "HSSPortal.Business.Models",
autoGeneratedKeyType: _autoGeneratedKeyType.Identity
});
entityType.addProperty(new _dataProperty({
name: "customerId",
dataType: _dataType.String,
isNullable: false,
isPartOfKey: true
}));
entityType.addProperty(new _dataProperty({
name: "firstName",
dataType: _dataType.String,
isNullable: false
}));
entityType.addProperty(new _dataProperty({
name: "lastName",
dataType: _dataType.String,
isNullable: false
}));
_store.addEntityType(entityType);
Upvotes: 0
Views: 538
Reputation: 17052
My guess is that the type that you are creating on the server does not have a name that matches the name you have registered on the client. In this case you have a client side type that would match to a server side type named "Employee" in the "HSSPortal.Business.Models" namespace.
You can change either the client type registration code or the server side type so that your type names match. Or, you can use a JsonResultsAdapter to interpret the serialized type name from the server to a registered type on the client. This approach is probably NOT needed in your case.
One minor note: in the code above you are not actually registering a breeze "ComplexType" here. A complex type is created via the AddComplexType method, and will not have either key properties or an AutoGeneratedKeyType. Conceptually "ComplexTypes" represent a collection of properties that are not queryable except in the context of their parent entity.
If you are in fact registering complex types in your code (not shown above) then they will have similar naming issues.
Upvotes: 1