I have a Web API 2 service that has a Breeze Controller that connects to entity framework. It gets several EntityTypes from tables in my database (like Employee, UserConfiguration, Shipment etc)
It all works great.
But now I want to make a "custom" EntityType. One called User. I don't actually have a User table in my database. I am using a few different sources to make an instance of User. (Employee Table, UserConfiguration Table and a Service Call)
When I make the call to my GetCurrentUser method, the data is returned correctly to the client.
But I have this setup to allow my constructor to be called when breeze creates the object:
metadataStore.registerEntityTypeCtor('User', Entities.User, this.setupEntity);
But the constructor never gets called.
How can I make it see the User entity?
Note: If possible, I would prefer to set this up in my Web API code, rather than in my JavaScript/TypeScript.
In case it is relevant, here is part of my User class:
[DataContract]
public class User
{
public User(Employee employee, ApplicationPermission permissions,
UserConfiguration userConfiguration)
{
EmployeeId = employee.EmployeeId;
LanId = employee.LanId;
FirstName = employee.FirstName;
LastName = employee.LastName;
UserPermissions = new List<UserPermission>();
UserConfiguration = userConfiguration;
}
[DataMember]
int? EmployeeId { get; set; }
[DataMember]
string FirstName { get; set; }
[DataMember]
string LastName { get; set; }
[DataMember]
List<UserPermission> UserPermissions { get; set; }
[DataMember]
private UserConfiguration UserConfiguration { get; set; }
}
function addFilterType(metadataStore) { metadataStore.addEntityType({ shortName: "Filter", autoGeneratedKeyType: breeze.AutoGeneratedKeyType.Identity, dataProperties: { id: { ....so apparently i used addEntityType, not register constructor. Have you tried that? - HotTowelie