Type Properties in Entity Framework
The example below illustrates how to implement Type Properties in an Entity Framework Code-First class.
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using DevExpress.ExpressApp.Utils;
// ...
[NotMapped]
[TypeConverter(typeof(LocalizedClassInfoTypeConverter))]
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 string DataTypeName { get; set; }