Ejemplo n.º 1
0
        public SlimProperty(
            string name,
            Type clrType,
            PropertyInfo?propertyInfo,
            FieldInfo?fieldInfo,
            SlimEntityType declaringEntityType,
            PropertyAccessMode propertyAccessMode,
            bool nullable,
            bool concurrencyToken,
            ValueGenerated valueGenerated,
            PropertySaveBehavior beforeSaveBehavior,
            PropertySaveBehavior afterSaveBehavior,
            int?maxLength,
            bool?unicode,
            int?precision,
            int?scale,
            Type?providerClrType,
            Func <IProperty, IEntityType, ValueGenerator>?valueGeneratorFactory,
            ValueConverter?valueConverter,
            ValueComparer?valueComparer,
            ValueComparer?keyValueComparer,
            CoreTypeMapping?typeMapping)
            : base(name, propertyInfo, fieldInfo, propertyAccessMode)
        {
            DeclaringEntityType    = declaringEntityType;
            ClrType                = clrType;
            _isNullable            = nullable;
            _isConcurrencyToken    = concurrencyToken;
            _valueGenerated        = valueGenerated;
            _beforeSaveBehavior    = beforeSaveBehavior;
            _afterSaveBehavior     = afterSaveBehavior;
            _valueGeneratorFactory = valueGeneratorFactory;
            _valueConverter        = valueConverter;

            if (maxLength != null)
            {
                SetAnnotation(CoreAnnotationNames.MaxLength, maxLength);
            }
            if (unicode != null)
            {
                SetAnnotation(CoreAnnotationNames.Unicode, unicode);
            }
            if (precision != null)
            {
                SetAnnotation(CoreAnnotationNames.Precision, precision);
            }
            if (scale != null)
            {
                SetAnnotation(CoreAnnotationNames.Scale, scale);
            }
            if (providerClrType != null)
            {
                SetAnnotation(CoreAnnotationNames.ProviderClrType, providerClrType);
            }

            _typeMapping      = typeMapping;
            _valueComparer    = valueComparer ?? TypeMapping.Comparer;
            _keyValueComparer = keyValueComparer ?? TypeMapping.KeyComparer;
        }
Ejemplo n.º 2
0
 public SlimCheckConstraint(
     string name,
     SlimEntityType entityType,
     string sql)
 {
     EntityType = entityType;
     Name       = name;
     Sql        = sql;
 }
Ejemplo n.º 3
0
 public SlimIndex(
     IReadOnlyList <SlimProperty> properties,
     SlimEntityType declaringEntityType,
     string?name,
     bool unique)
 {
     Properties          = properties;
     Name                = name;
     DeclaringEntityType = declaringEntityType;
     _isUnique           = unique;
 }
Ejemplo n.º 4
0
        public SlimServiceProperty(
            string name,
            PropertyInfo?propertyInfo,
            FieldInfo?fieldInfo,
            SlimEntityType declaringEntityType,
            PropertyAccessMode propertyAccessMode)
            : base(name, propertyInfo, fieldInfo, propertyAccessMode)
        {
            Check.NotNull(declaringEntityType, nameof(declaringEntityType));

            DeclaringEntityType = declaringEntityType;
            ClrType             = (propertyInfo?.PropertyType ?? fieldInfo?.FieldType) !;
        }
Ejemplo n.º 5
0
 public SlimForeignKey(
     IReadOnlyList <SlimProperty> dependentProperties,
     SlimKey principalKey,
     SlimEntityType dependentEntityType,
     SlimEntityType principalEntityType,
     DeleteBehavior deleteBehavior,
     bool unique,
     bool required,
     bool requiredDependent,
     bool ownership)
 {
     Properties           = dependentProperties;
     PrincipalKey         = principalKey;
     DeclaringEntityType  = dependentEntityType;
     PrincipalEntityType  = principalEntityType;
     _isRequired          = required;
     _isRequiredDependent = requiredDependent;
     _deleteBehavior      = deleteBehavior;
     _isUnique            = unique;
     _isOwnership         = ownership;
 }
Ejemplo n.º 6
0
        public SlimSkipNavigation(
            string name,
            Type clrType,
            PropertyInfo?propertyInfo,
            FieldInfo?fieldInfo,
            SlimEntityType declaringEntityType,
            SlimEntityType targetEntityType,
            SlimForeignKey foreignKey,
            bool collection,
            bool onDependent,
            PropertyAccessMode propertyAccessMode,
            bool eagerLoaded)
            : base(name, propertyInfo, fieldInfo, propertyAccessMode)
        {
            ClrType             = clrType;
            DeclaringEntityType = declaringEntityType;
            TargetEntityType    = targetEntityType;
            _foreignKey         = foreignKey;
            if (foreignKey.ReferencingSkipNavigations == null)
            {
                foreignKey.ReferencingSkipNavigations = new SortedSet <SlimSkipNavigation>(SkipNavigationComparer.Instance)
                {
                    this
                };
            }
            else
            {
                foreignKey.ReferencingSkipNavigations.Add(this);
            }

            _isCollection  = collection;
            _isOnDependent = onDependent;
            if (eagerLoaded)
            {
                SetAnnotation(CoreAnnotationNames.EagerLoaded, true);
            }
        }