How to hide a column in a code-first entity (RIA)
I thought that would have been simple but it is not working.
I can, from the lightswitch screen designer, hide a field so that it is not visible at runtime. I see that lightswitch adds a Hidden attribute to the field in its lsml file.
But, how would I have a default of not visible for some fields coming from RIA services ?
I tried adding a ScaffoldColum(false) attribute to the entity field... no effect. (even tried true just in case I 开发者_开发问答misunderstood the attribute).
Furthermore I tried other attributes without success.
- Display(AutoGenerateField = false)
- EditorBrowsable(EditorBrowsableState.Never)
When you create a RIA service, & attach it as a data source, LightSwitch treats it as an entity/table, the same as any of it's own entities. Even though the LSMLS file has "hidden" attributes applied to some properties, this really only means that the "Display By Default" checkbox has been unticked for that property in the table designer.
Unticking this box means that in any auto-generated screens that property won't be displayed. If you create your own screen, based on an entity, the screen designer will omit adding those properties to the visual tree.
The only way I know of to "hide" a property is to uncheck that box in the table designer, but it has to be done in LS, it can't be done in the RIA service itself. Maybe in a future version, if enough people express a desire for this functionality. You can alway go to the Connect website & submit a "suggestion".
精彩评论