Skip to main content
.NET 6.0+

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))]
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; }