entity framework - Breeze JS Adding a static Lookup dictionary to Metadata -
one of domain models has enum property create dropdown box for, efcontextprovide metadata function doesn't automatically import enum entity type me access it, created static dictionay of add metadata mapping, acting lookup table. how can add enum entity type, can call:
breeze.entitymanager.createentity(myenum,...)
right now, following error:
error: unable locate 'type' name: myenum
any suggestion?
update: (i added enumtype
info of metadata
function call)
"enumtype":{"name":"plugins","isflags":"false","underlyingtype":"int32","member":["name":"custom","value":"0"},{"name":"pluginoftypea","value":"1"},{"name":"pluginoftypeb","value":"2"}]}
thanks @jay response, set in right direction. here can dealing enum:
i created lookup list on server can separately call, populate dropdown list. have regular array initialize on success promise of results, list data.results[0].myenumlookup
, on viewmodel, access property , set in ko.observablearray()
can refer in view. make sure set value:
property of select
tag, value of item.
but problem doing way @ save time, wasn't reading enum value , treating text, failing, so
more robust solution:
in our application happen benefit having enum , pre-compile value, since using enum domain models in other poco projects, ended creating ef dbset
, proper table populated of enums values , can save them db, have list of items in db, , created single level of inheritance enums, in controller, iqueryable
method of enums, , in breeze application, in config file, define types of enums, , populate lists of items based on different types in config, can refer in view , binding ko.observablearray()
. in original class, no longer refer enum, create myenumid
virtual myenum
property mapping automatically in ef5 setup.
lesson learned, though enum in .net4.5 & ef5 possible store , read back, it's not practical when comes spa front-end technologies, prefer having integer value, , manage enums outside of it.
Comments
Post a Comment