public void Datetime2WithPrecision() { var testCase = new SqlTypeColumnTestCase() { ColumnDeclaration = "datetime2(4)", ExpectedSqlType = SqlType.DateTime("datetime2", 4) }; RunTestCase(testCase); }
public static SqlType DateTime2(int?fractionalSecondsPrecision = 7) { if (fractionalSecondsPrecision is < 0 or > 7) { throw new ArgumentException("FractionalSecondsPrecision must be between 0 and 7 inclusive.", nameof(fractionalSecondsPrecision)); } return(SqlType.DateTime("datetime2", fractionalSecondsPrecision)); }
public static SqlType FromInformationSchemaColumn(SISColumn col) { if (SqlTypes.IsDateTime(col.DATA_TYPE)) { return(SqlType.DateTime(col.DATA_TYPE, col.DATETIME_PRECISION)); } if (SqlTypes.IsApproximateNumeric(col.DATA_TYPE)) { if (col.DATA_TYPE == "float") { return(SqlTypeFactory.Float(col.NUMERIC_PRECISION.Value)); } if (col.DATA_TYPE == "real") { return(SqlTypeFactory.Real()); } } if (SqlTypes.IsExactNumeric(col.DATA_TYPE)) { return(SqlType.ExactNumericType(col.DATA_TYPE, col.NUMERIC_PRECISION, col.NUMERIC_PRECISION_RADIX)); } if (SqlTypes.IsCharType(col.DATA_TYPE)) { return(SqlType.TextType(col.DATA_TYPE, col.CHARACTER_MAXIMUM_LENGTH)); } if (col.DATA_TYPE.Equals("uniqueidentifier", StringComparison.InvariantCultureIgnoreCase)) { return(SqlType.Type(col.DATA_TYPE)); } if (col.DATA_TYPE.Equals("varbinary", StringComparison.InvariantCultureIgnoreCase)) { return(SqlType.Type(col.DATA_TYPE)); } throw new NotImplementedException($"Unknown type {col.DATA_TYPE}"); }
public static ExprCast LiteralCast(DateTime value, bool isDate = false) => Cast(Literal(value), SqlType.DateTime(isDate));