예제 #1
0
 public override DbTypeInfo GetDbTypeInfo(string typeSpec, EntityMemberInfo forMember)
 {
     if (typeSpec.EndsWith("(max)", StringComparison.OrdinalIgnoreCase))
     {
         if (!TypeDefsByName.TryGetValue(typeSpec, out var stype))
         {
             return(null);
         }
         return(stype.DefaultTypeInfo);
     }
     return(base.GetDbTypeInfo(typeSpec, forMember));
 }
예제 #2
0
        public virtual DbTypeInfo GetDbTypeInfo(string typeSpec, EntityMemberInfo forMember)
        {
            var dataType       = forMember.DataType;
            var fullName       = forMember.Entity.Name + "." + forMember.MemberName;
            var parsedTypeSpec = this.ParseTypeSpec(typeSpec);

            if (!TypeDefsByName.TryGetValue(parsedTypeSpec.TypeName, out var storageType))
            {
                Util.Throw($"Member {fullName}: failed to map DB type {parsedTypeSpec.TypeName}.");
            }
            if (storageType.DefaultTypeInfo != null)
            {
                return(storageType.DefaultTypeInfo);
            }
            var baseType = forMember.DataType.GetUnderlyingStorageClrType();
            var mapping  = MapWithArgs(baseType, storageType, parsedTypeSpec.Args);

            return(mapping);
        }
예제 #3
0
        // IDbTypeRegistry implementation
        public virtual DbTypeInfo GetDbTypeInfo(string typeName, long size = 0, byte prec = 0, byte scale = 0)
        {
            if (!TypeDefsByName.TryGetValue(typeName, out DbTypeDef typeDef))
            {
                return(null);
            }
            if (typeDef.DefaultTypeInfo != null)
            {
                return(typeDef.DefaultTypeInfo);
            }
            if (size == 0 && typeDef.Flags.IsSet(DbTypeFlags.Unlimited))
            {
                size = -1;
            }
            // we have storage type that requires arguments (ex: varchar). Create mapping with args
            var typeSpec = FormatTypeSpec(typeDef, size, prec, scale);

            return(CreateDbTypeInfo(typeDef.ColumnOutType, typeDef, size, prec, scale));
        }