I'm extending an entity from the entity framework by adding an extra property: Example:
public partial class Product
{
public string DefaultProductCode { get; set; }
I set this property with a hardcoded value to test, before it gets returned in the IQueryable < Product > in the breeze controller. This property is successfully shown in the json code when I call my breeze method using a browser.
I'm trying to display this extra property in a grid, but I kept having this error:
Error retreiving data. Object doesn't support property or method 'defaultProductCode'
I could solve the error, by registering the property defaultProductCode in the constructor of the Product. Example:
var Product = function () {
this.defaultProductCode = ko.observable("");
};
metadataStore.registerEntityTypeCtor('Product', Product, productInitializer);
But the problem is that it always shows the value from the constructor, it never shows the value that comes from the server, even though I'm seeing that it's successfully coming through.
Is this is a bug? Is there a way to register that extra property so it displays the value that comes from the server?
I second PW-Kad's recommendation to look at How to extend Breeze MetaData for Unmapped Entity Property without KO. Look also at this StackOverflow Q&A which appears to address your use case.