/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> // Note: only use this to find the property/field that defines the property in the model. Use // GetMemberInfo to get the property/field to use, which may be different. public static MemberInfo?GetIdentifyingMemberInfo( this IReadOnlyPropertyBase propertyBase) { var indexerPropertyInfo = propertyBase.DeclaringType.FindIndexerPropertyInfo(); return(indexerPropertyInfo != null && propertyBase.PropertyInfo == indexerPropertyInfo ? null : (propertyBase.PropertyInfo ?? (MemberInfo?)propertyBase.FieldInfo)); }
static void CheckValueGenerationStrategy(IReadOnlyPropertyBase property, FbValueGenerationStrategy?value) { if (value != null) { if (value == FbValueGenerationStrategy.IdentityColumn && !IsCompatibleIdentityColumn(property)) { throw new ArgumentException($"Incompatible data type for {nameof(FbValueGenerationStrategy.IdentityColumn)} for '{property.Name}'."); } if (value == FbValueGenerationStrategy.SequenceTrigger && !IsCompatibleSequenceTrigger(property)) { throw new ArgumentException($"Incompatible data type for {nameof(FbValueGenerationStrategy.SequenceTrigger)} for '{property.Name}'."); } } }
public static MemberInfo?GetIdentifyingMemberInfo( [NotNull] this IReadOnlyPropertyBase propertyBase) => propertyBase.PropertyInfo ?? (MemberInfo?)propertyBase.FieldInfo;
public static PropertyBase AsPropertyBase( [NotNull] this IReadOnlyPropertyBase propertyBase, [NotNull][CallerMemberName] string methodName = "") => MetadataExtensions.AsConcreteMetadataType <IReadOnlyPropertyBase, PropertyBase>(propertyBase, methodName);
static bool IsCompatibleSequenceTrigger(IReadOnlyPropertyBase property) => true;
static bool IsCompatibleIdentityColumn(IReadOnlyPropertyBase property) => property.ClrType.IsInteger() || property.ClrType == typeof(decimal);
public static bool IsIndexerProperty([NotNull] this IReadOnlyPropertyBase property) => Check.NotNull(property, nameof(property)).GetIdentifyingMemberInfo() is PropertyInfo propertyInfo &&
public static bool IsShadowProperty([NotNull] this IReadOnlyPropertyBase property) => Check.NotNull(property, nameof(property)).GetIdentifyingMemberInfo() == null;
public static string?GetFieldName([NotNull] this IReadOnlyPropertyBase propertyBase) => propertyBase.FieldInfo?.GetSimpleMemberName();
public static IComparer <IUpdateEntry> GetCurrentValueComparer([NotNull] this IReadOnlyPropertyBase propertyBase) => propertyBase.AsPropertyBase().CurrentValueComparer;