Exemplo n.º 1
0
		protected override string? GetDbType(GetSchemaOptions options, string? columnType, DataTypeInfo? dataType, long? length, int? precision, int? scale, string? udtCatalog, string? udtSchema, string? udtName)
		{
			// database name for udt not supported by sql server
			if (udtName != null)
				return (udtSchema != null ? SqlServerTools.QuoteIdentifier(udtSchema) + '.' : null) + SqlServerTools.QuoteIdentifier(udtName);

			return base.GetDbType(options, columnType, dataType, length, precision, scale, udtCatalog, udtSchema, udtName);
		}
Exemplo n.º 2
0
        protected override string GetDbType(string columnType, DataTypeInfo dataType, long?length, int?prec, int?scale, string udtCatalog, string udtSchema, string udtName)
        {
            // database name for udt not supported by sql server
            if (udtName != null)
            {
                return((udtSchema != null ? SqlServerTools.QuoteIdentifier(udtSchema) + '.' : null) + SqlServerTools.QuoteIdentifier(udtName));
            }

            return(base.GetDbType(columnType, dataType, length, prec, scale, udtCatalog, udtSchema, udtName));
        }
Exemplo n.º 3
0
        public override object Convert(object value, ConvertType convertType)
        {
            switch (convertType)
            {
            case ConvertType.NameToQueryParameter:
            case ConvertType.NameToCommandParameter:
            case ConvertType.NameToSprocParameter:
                return("@" + value);

            case ConvertType.NameToQueryField:
            case ConvertType.NameToQueryFieldAlias:
            case ConvertType.NameToQueryTableAlias:
            {
                var name = value.ToString();

                if (name.Length > 0 && name[0] == '[')
                {
                    return(value);
                }

                return(SqlServerTools.QuoteIdentifier(name));
            }

            case ConvertType.NameToDatabase:
            case ConvertType.NameToSchema:
            case ConvertType.NameToQueryTable:
                if (value != null)
                {
                    var name = value.ToString();

                    if (name.Length > 0 && name[0] == '[')
                    {
                        return(value);
                    }

//						if (name.IndexOf('.') > 0)
//							value = string.Join("].[", name.Split('.'));

                    return(SqlServerTools.QuoteIdentifier(name));
                }

                break;

            case ConvertType.SprocParameterToName:
                if (value != null)
                {
                    var str = value.ToString();
                    return(str.Length > 0 && str[0] == '@'? str.Substring(1): str);
                }
                break;
            }

            return(value);
        }
Exemplo n.º 4
0
        public override StringBuilder Convert(StringBuilder sb, string value, ConvertType convertType)
        {
            switch (convertType)
            {
            case ConvertType.NameToQueryParameter:
            case ConvertType.NameToCommandParameter:
            case ConvertType.NameToSprocParameter:
                return(sb.Append('@').Append(value));

            case ConvertType.NameToQueryField:
            case ConvertType.NameToQueryFieldAlias:
            case ConvertType.NameToQueryTableAlias:
                if (value.Length > 0 && value[0] == '[')
                {
                    return(sb.Append(value));
                }

                if (value == "$action")
                {
                    return(sb.Append(value));
                }

                return(SqlServerTools.QuoteIdentifier(sb, value));

            case ConvertType.NameToServer:
            case ConvertType.NameToDatabase:
            case ConvertType.NameToSchema:
            case ConvertType.NameToQueryTable:
            case ConvertType.NameToProcedure:
                if (value.Length > 0 && value[0] == '[')
                {
                    return(sb.Append(value));
                }

                return(SqlServerTools.QuoteIdentifier(sb, value));

            case ConvertType.SprocParameterToName:
                return(value.Length > 0 && value[0] == '@'
                                                ? sb.Append(value.Substring(1))
                                                : sb.Append(value));
            }

            return(sb.Append(value));
        }