Entity framework 在业务对象内指定属性编辑器
我将Entity framework 在业务对象内指定属性编辑器,entity-framework,devexpress,xaf,Entity Framework,Devexpress,Xaf,我将devexpressXAF与实体框架一起使用。 我希望能够指定我的Description字段使用属性编辑器DevExpress.ExpressApp.HtmlPropertyEditor.Win.HtmlPropertyEditor 我可以通过在涉及该字段的视图中设置model.xafml内的属性编辑器来实现这一点。但是,我更愿意在business对象中将其作为属性设置一次 有办法做到这一点吗?develxpress知识库在这里解释了如何实现这一点:。见第2.2节和第2.3节 如果业务对象与
devexpress
XAF
与实体框架一起使用。
我希望能够指定我的Description
字段使用属性编辑器DevExpress.ExpressApp.HtmlPropertyEditor.Win.HtmlPropertyEditor
我可以通过在涉及该字段的视图中设置model.xafml
内的属性编辑器来实现这一点。但是,我更愿意在business
对象中将其作为属性设置一次
有办法做到这一点吗?develxpress知识库在这里解释了如何实现这一点:。见第2.2节和第2.3节
如果业务对象与编辑器在同一模块中声明,则可以执行以下操作:
//Class declared in a WinForms module, for example
public class BusinessObject : BaseObject {
...
[ModelDefault("PropertyEditorType", "SampleSolution.Module.Win.PropertyEditors.CustomStringEditor")]
public string Description {
get { return GetPropertyValue<string>("Description"); }
set { SetPropertyValue<string>("Description", value); }
}
}
并在编辑器中设置相同的字符串标识符。(这允许在单独的Web和Win模块中指定不同的编辑器)
我在独立于平台的模块中声明了业务对象。我需要它,因为这是实体框架上下文所在的位置。所以使用EditorAlias
,如2.3所述。
public class BusinessObject : BaseObject {
...
[EditorAlias("CustomStringEdit")]
public string Description {
get { return GetPropertyValue<string>("Description"); }
set { SetPropertyValue<string>("Description", value); }
}
}
[PropertyEditor(typeof(String), "CustomStringEdit", false)]
public class CustomStringEditor : StringPropertyEditor {
public CustomStringEditor(Type objectType, IModelMemberViewItem info)
: base(objectType, info) { }
...
}