Beispiel #1
0
        public virtual RelationalTypeMapping GetMapping(Type clrType)
        {
            Check.NotNull(clrType, nameof(clrType));

            RelationalTypeMapping mapping;

            if (SimpleMappings.TryGetValue(clrType.UnwrapEnumType(), out mapping))
            {
                return(mapping);
            }

            throw new NotSupportedException(RelationalStrings.UnsupportedType(clrType.Name));
        }
Beispiel #2
0
        public virtual RelationalTypeMapping FindMapping([NotNull] Type clrType)
        {
            Check.NotNull(clrType, nameof(clrType));

            RelationalTypeMapping mapping;

            if (SimpleMappings.TryGetValue(clrType.UnwrapNullableType().UnwrapEnumType(), out mapping))
            {
                return(mapping);
            }

            return(null);
        }
Beispiel #3
0
        public virtual RelationalTypeMapping GetMapping(IProperty property)
        {
            Check.NotNull(property, nameof(property));

            RelationalTypeMapping mapping = null;

            var typeName = GetColumnType(property);

            if (typeName != null)
            {
                var paren = typeName.IndexOf("(", StringComparison.Ordinal);
                SimpleNameMappings.TryGetValue((paren >= 0 ? typeName.Substring(0, paren) : typeName).ToLowerInvariant(), out mapping);
            }

            return(mapping
                   ?? (SimpleMappings.TryGetValue(property.ClrType.UnwrapEnumType().UnwrapNullableType(), out mapping)
                       ? mapping
                       : GetCustomMapping(property)));
        }