breeze - How to add a property to an EntityType after it has been added to the Data Store? -


i have entity framework code first model column not mapped still want persist between server , client. model looks similar many more properties:

public class ownerinformation {     [key]     [databasegeneratedattribute(databasegeneratedoption.identity)]     public int id { get; set; }      [required]     [maxlength(16)]     public byte[] ssnencrypted { get; set; }      [notmapped]     [maxlength(9)]     [minlength(9)]     public string ssn { get; set; } } 

when metadata retrieved breeze ssn not part of it, when data sent on wire ssn there. let breeze deal mapping through metadata, able still pass ssn between client , server , track it's state need encrypt before saved db.

i tried adding after metadata fetched this:

var ownertype = manager.metadatastore.getentitytype('ownerinformation'); var ssn = new breeze.dataproperty({   name: 'ssn',   datatype: breeze.datatype.string,   isnullable: false,   maxlength: 9 }); ownertype.addproperty(ssn); 

but error: the 'ownerinformation:#models' entitytype has been added metadatastore , therefore no additional properties may added it.

maybe i'm overthinking , there easier way. i'm opened suggestions.

i took different approach , decided change metadata @ runtime on server. here's how did it.

public class mycontextprovider : efcontextprovider<mycontext> {   protected override string buildjsonmetadata()   {     string metadata = base.buildjsonmetadata();     jobject json = jobject.parse(metadata);     var entityownerinfo = json["schema"]["entitytype"].children().where(j => (string)j["name"] == "ownerinformation").singleordefault();     var propertyarray = entityownerinfo["property"] newtonsoft.json.linq.jarray;      jtoken ssnpropertytype = jtoken.parse(@"{       ""name"": ""ssn"",       ""type"": ""edm.string"",       ""fixedlength"": ""true"",       ""maxlength"": ""9"",       ""minlength"": ""9"",       ""nullable"": ""false""}");     propertyarray.add(ssnpropertytype);      return json.tostring();   } } 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -