public VendorDbTypeInfo(string typeName, DbType dbType, Type columnOutType, string argsTemplate, string argsTemplateUnlimitedSize, Type[] clrTypes, Type dbFirstClrType, VendorDbTypeFlags flags, string aliases, DbValueToLiteralConvertFunc 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.SplitNames(',', ';')); } VendorDbType = vendorDbType; DefaultColumnInit = columnInit; ValueToLiteral = valueToLiteral ?? DbValueToLiteralConverters.GetDefaultToLiteralConverter(columnOutType); }
public VendorDbTypeInfo AddType <TVendorType>(string typeName, DbType dbType, Type columnOutType, TVendorType vendorDbType, bool isDefault = true, bool supportsMemo = false, bool isSubType = false, string args = null, string memoArgs = null, Type[] clrTypes = null, Type dbFirstClrType = null, string aliases = null, string columnInit = null, DbValueToLiteralConvertFunc valueToLiteral = null) where TVendorType : struct { return(AddType(typeName, dbType, columnOutType, isDefault, supportsMemo, isSubType, args, memoArgs, clrTypes, dbFirstClrType, aliases, columnInit, (int)(object)vendorDbType, valueToLiteral)); }
public VendorDbTypeInfo AddType(string typeName, DbType dbType, Type columnOutType, bool isDefault = true, bool supportsMemo = false, bool isSubType = false, string args = null, string memoArgs = null, Type[] clrTypes = null, Type dbFirstClrType = null, string aliases = null, string columnInit = null, int vendorDbType = -1, DbValueToLiteralConvertFunc valueToLiteral = null) { //validate that we have only one default type for clr type if (isDefault && clrTypes != null) { foreach (var clrType in clrTypes) { var oldType = Types.FirstOrDefault(td => td.ClrTypes.Contains(clrType) && td.Flags.IsSet(VendorDbTypeFlags.IsDefaultForClrType)); Util.Check(oldType == null, "There is already Db type definition registered as default for CLR type {0}.", columnOutType); } } typeName = typeName.ToLowerInvariant(); var flags = VendorDbTypeFlags.None; if (isDefault) { flags |= VendorDbTypeFlags.IsDefaultForClrType; } if (supportsMemo) { flags |= VendorDbTypeFlags.SupportsUnlimitedSize; } if (isSubType) { flags |= VendorDbTypeFlags.IsSubType; } columnInit = columnInit ?? GetDefaultColumnInitExpression(columnOutType); var typeDef = new VendorDbTypeInfo(typeName, dbType, columnOutType, args, memoArgs, clrTypes, dbFirstClrType, flags, aliases, valueToLiteral, vendorDbType, columnInit); Types.Add(typeDef); return(typeDef); }