EPR类企业管理系统

在我们现有系统基础上或全新开发,提供定制服务
为您的企业高效快速实施ERP,WMS,MES,CRM管理系统
全面管控物料仓库、销售业务、采购业务、仓库业务
生产过程、质量检验、组织架构、业务报表


定制
QQ:460-3528

开发
QQ群:3360-90194

源码
微信:136-3650-3721

实体框架中的标准属性

下面的示例说明了如何在Entity Framework Code First类中实现条件属性

[Browsable(false)]
public string DataTypeName {
    get { return fDataType == null ? string.Empty : fDataType.FullName; }
    set {
        ITypeInfo typeInfo = XafTypesInfo.Instance.FindTypeInfo(value);
        fDataType = typeInfo == null ? null : typeInfo.Type;
    }
}
private Type fDataType;
[NotMapped, ImmediatePostData]
public Type DataType {
    get { return fDataType; }
    set {
        if (fDataType == value) return;
        fDataType = value;
        Criteria = string.Empty;
                   CriteriaInPopupWindow = string.Empty;
    }
}
[CriteriaOptions("DataType")]
[FieldSize(FieldSizeAttribute.Unlimited)]
[ObjectValidatorIgnoreIssue(typeof(ObjectValidatorLargeNonDelayedMember))]
[VisibleInListView(true)]
[EditorAlias(EditorAliases.CriteriaPropertyEditor)]
public string Criteria { get; set; }

[CriteriaOptions("DataType")]
[FieldSize(FieldSizeAttribute.Unlimited)]
[ObjectValidatorIgnoreIssue(typeof(ObjectValidatorLargeNonDelayedMember))]
[VisibleInListView(true)]
[EditorAlias(EditorAliases.PopupCriteriaPropertyEditor)]
public string CriteriaInPopupWindow { get; set; }
<Browsable(False)> _
Public Property DataTypeName() As String
    Get
        Return If(fDataType Is Nothing, String.Empty, fDataType.FullName)
    End Get
    Set(ByVal value As String)
        Dim typeInfo As ITypeInfo = XafTypesInfo.Instance.FindTypeInfo(value)
        fDataType = If(typeInfo Is Nothing, Nothing, typeInfo.Type)
    End Set
End Property
Private fDataType As Type
<NotMapped, ImmediatePostData> _
Public Property DataType() As Type
    Get
        Return fDataType
    End Get
    Set(ByVal value As Type)
        If fDataType = value Then
            Return
        End If
        fDataType = value
        Criteria = String.Empty
        CriteriaInPopupWindow = String.Empty
    End Set
End Property
<CriteriaOptions("DataType"), FieldSize(FieldSizeAttribute.Unlimited), _
ObjectValidatorIgnoreIssue(GetType(ObjectValidatorLargeNonDelayedMember)), VisibleInListView(True), _
EditorAlias(EditorAliases.CriteriaPropertyEditor)>
Public Property Criteria() As String

<CriteriaOptions("DataType"), FieldSize(FieldSizeAttribute.Unlimited), _
ObjectValidatorIgnoreIssue(GetType(ObjectValidatorLargeNonDelayedMember)), VisibleInListView(True), _
EditorAlias(EditorAliases.PopupCriteriaPropertyEditor)>
Public Property CriteriaInPopupWindow() As String

转载保留此链接,注明出处