private static IRefIdProperty RegisterRefIdCore <TKey>(string propertyName, ReferenceType referenceType, Type propertyType, PropertyMetadata <TKey> defaultMeta) { var property = new RefIdProperty <TKey>(typeof(TEntity), propertyName, defaultMeta) { ReferenceType = referenceType, Nullable = propertyType.IsClass || TypeHelper.IsNullable(propertyType) }; ManagedPropertyRepository.Instance.RegisterProperty(property); return(property); }
/// <summary> /// 扩展一个引用属性 /// </summary> /// <typeparam name="TKey">The type of the entity list.</typeparam> /// <param name="propertyName">属性名称。</param> /// <param name="declareType">声明此属性的类型。</param> /// <param name="isNullable">是否为一个可空的引用属性。</param> /// <returns></returns> public static IRefIdProperty RegisterRefIdExtension <TKey>(string propertyName, Type declareType, bool isNullable = false) where TKey : struct { var property = new RefIdProperty <TKey>(typeof(TEntity), declareType, propertyName, new RegisterRefIdArgs <TKey>()) { ReferenceType = ReferenceType.Normal, Nullable = isNullable }; ManagedPropertyRepository.Instance.RegisterProperty(property); return(property); }