-
Notifications
You must be signed in to change notification settings - Fork 317
Closed
Milestone
Description
SqlConnection's method GetSchema("DataTypes") returns following results for "tinyint" data type
- DataType: System.SByte
- IsUnsigned:True
This result is inconsistent and it seems it should return System.Byte as DataType,
because SQLServer's tinyint data type is defined to be mapped to .NET byte type (0-254)
https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mappings
Example code to reproduce problems
var conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=TestDB;Integrated Security=True;");
conn.Open();
var rows = conn.GetSchema(DbMetaDataCollectionNames.DataTypes)
.Rows
.OfType<DataRow>()
.Where(p=>(string)p["TypeName"]== "tinyint");
foreach (var row in rows)
{
Console.WriteLine(String.Format("TypeName:{0,-25} DataType:{1,-30} IsUnsigned:{2,-15}",
row["TypeName"],
row["DataType"],
row["IsUnsigned"]
));
}
//Output:
//TypeName:tinyint DataType:System.SByte IsUnsigned:True Root cause of problems
It seems SqlConnection GetSchema("DataTypes") method return results from following xml definition file.
Reproducible environments
I've confirmed this problem occurs following environments
- .NET 4.6.1
- .NET Core 2.0 with System.Data.SqlClient/4.4.0-preview2-25405-01
Note
It seems following issue mentioned this wrong tinyint datatype.
fsprojects/SQLProvider#69
bgribaudo
Metadata
Metadata
Assignees
Labels
No labels