public DbTypeDefinition(string typeName, DbType dbType, Type columnOutType, string argsTemplate, string argsTemplateUnlimitedSize, Type[] clrTypes, Type dbFirstClrType, DbTypeFlags flags, string aliases, FuncValueToLiteral valueToLiteral, int vendorDbType = -1, string columnInit = null) { TypeName = typeName; DbType = dbType; ArgsTemplate = argsTemplate; ArgsTemplateUnlimitedSize = argsTemplateUnlimitedSize ?? argsTemplate; ColumnOutType = columnOutType; DbFirstClrType = dbFirstClrType ?? ColumnOutType; if (clrTypes != null) { ClrTypes.UnionWith(clrTypes); } ClrTypes.Add(ColumnOutType); ClrTypes.Add(DbFirstClrType); Flags = flags; if (!string.IsNullOrWhiteSpace(aliases)) { Aliases.AddRange(aliases.Split(',', ';')); } VendorDbType = vendorDbType; DefaultColumnInit = columnInit; ValueToLiteral = valueToLiteral; }
public virtual DbTypeDef AddDbTypeDef(string name, Type columnOutType, DbTypeFlags flags = DbTypeFlags.None, string specTemplate = null, string aliases = null, byte?defaultPrecision = null, byte?defaultScale = null, ToLiteralFunc toLiteral = null, string columnInit = null, bool mapColumnType = true, //map to column out type if typeDef has no args and not unlimited object providerDbType = null, //used by Postgres only DbSpecialType specialType = DbSpecialType.None) { var arrAliases = string.IsNullOrEmpty(aliases) ? _emptyStrings : aliases.Split(','); toLiteral = toLiteral ?? DbValueToLiteralConverters.GetDefaultToLiteralConverter(columnOutType); columnInit = columnInit ?? GetDefaultColumnInitExpression(columnOutType); var typeDef = new DbTypeDef() { Name = name, ColumnOutType = columnOutType, Flags = flags, Aliases = arrAliases, ToLiteral = toLiteral, ColumnInit = columnInit, DefaultPrecision = defaultPrecision, DefaultScale = defaultScale }; TypeDefsByName.Add(name, typeDef); // register under aliases foreach (var alias in typeDef.Aliases) { TypeDefsByName.Add(alias, typeDef); } if (specialType != DbSpecialType.None) { Util.Check(!SpecialTypeDefs.ContainsKey(specialType), "TypeDef for special type {0} already registered.", specialType); SpecialTypeDefs[specialType] = typeDef; } // Register by columnOutType if (!TypeDefsByColumnOutType.ContainsKey(columnOutType)) { TypeDefsByColumnOutType[columnOutType] = typeDef; } // If has a form without args, register it as default type def if (!flags.IsSet(DbTypeFlags.HasArgs)) { typeDef.DefaultTypeInfo = CreateDbTypeInfo(columnOutType, typeDef); if (mapColumnType && !flags.IsSet(DbTypeFlags.Unlimited) && !DbTypesByClrType.ContainsKey(columnOutType)) { DbTypesByClrType[columnOutType] = typeDef.DefaultTypeInfo; } } if (providerDbType != null) { typeDef.ProviderDbType = (int)providerDbType; } return(typeDef); }
public DbTypeDefinition(string typeName, DbType dbType, Type columnOutType, string argsTemplate, string argsTemplateUnlimitedSize, Type[] clrTypes, Type dbFirstClrType, DbTypeFlags flags, string aliases, FuncValueToLiteral valueToLiteral, int vendorDbType = -1, string columnInit = null) { TypeName = typeName; DbType = dbType; ArgsTemplate = argsTemplate; ArgsTemplateUnlimitedSize = argsTemplateUnlimitedSize ?? argsTemplate; ColumnOutType = columnOutType; DbFirstClrType = dbFirstClrType ?? ColumnOutType; if (clrTypes != null) ClrTypes.UnionWith(clrTypes); ClrTypes.Add(ColumnOutType); ClrTypes.Add(DbFirstClrType); Flags = flags; if (!string.IsNullOrWhiteSpace(aliases)) Aliases.AddRange(aliases.Split(',', ';')); VendorDbType = vendorDbType; DefaultColumnInit = columnInit; ValueToLiteral = valueToLiteral; }
public static bool IsSet(this DbTypeFlags flags, DbTypeFlags flag) { return((flags & flag) != 0); }
public static bool IsSet(this DbTypeFlags flags, DbTypeFlags flag) { return (flags & flag) != 0; }