Type Properties in EF Core
The example below illustrates how to implement Type Properties in an EF Core class.
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using DevExpress.ExpressApp.Utils;
// ...
[NotMapped]
[TypeConverter(typeof(LocalizedClassInfoTypeConverter))]
[HideInUI(HideInUI.FilterEditor)]
public Type DataType {
get {
Type result = null;
if (!String.IsNullOrWhiteSpace(DataTypeName)) {
ITypeInfo typeInfo = XafTypesInfo.Instance.FindTypeInfo(DataTypeName);
if (typeInfo != null) {
result = typeInfo.Type;
}
}
return result;
}
set {
if (value != null) {
DataTypeName = value.FullName;
}
else {
DataTypeName = "";
}
}
}
[Browsable(false)]
public virtual string DataTypeName { get; set; }
Filter Editor does not support Type properties, so we hide these properties with the HideInUI(HideInUI.FilterEditor) attribute. If you want to filter by type, add a string property as follows:
[HideInUI(HideInUI.DetailView | HideInUI.ReportCustomizationForm | HideInUI.DashboardCustomizationForm | HideInUI.ListView)]
[System.ComponentModel.DisplayName("Data Type")]
public string DataTypeCaption {
get { return CaptionHelper.GetClassCaption(DataTypeName);
}
}
If the view is not editable, use the following combination of attributes:
[HideInUI(HideInUI.DetailView | HideInUI.ReportCustomizationForm | HideInUI.DashboardCustomizationForm)]
[System.ComponentModel.DisplayName("Data Type")]
public string DataTypeCaption {...}
[HideInUI(HideInUI.FilterEditor | HideInUI.ListView)]
public Type DataType {...}