public void UniqueIdentifierToGuid() { var column = new Column { ColumnType = "uniqueIdentifier" }; var result = mapper.DBTypeToDataType(column); Assert.AreEqual("uniqueIdentifier", result.DbType); Assert.AreEqual(typeof(Guid?), result.SystemType); }
private Table AddTableAndColumns(DataRow row, Table currentTable) { var objectType = row["ObjectType"].ToString().Trim(); DBOjectType currentObjectType = objectType.SetObjectType(); if (currentTable == null || $"{currentTable.Database}.{currentTable.Schema}.Tables{currentTable.Name}" != $"{row["DatabaseName"]}.{row["TableSchema"]}.Tables{row["TableName"]}") { switch (currentObjectType) { case DBOjectType.Table: currentTable = new Table() { Schema = row["TableSchema"].ToString(), Name = row["TableName"].ToString(), Database = row["DatabaseName"].ToString(), PrimaryKeys = row["PKColumnName"].ToString() }; _dbSchema.Tables.Add(currentTable); break; case DBOjectType.View: currentTable = new View() { Schema = row["TableSchema"].ToString(), Name = row["TableName"].ToString(), Database = row["DatabaseName"].ToString(), PrimaryKeys = row["PKColumnName"].ToString() }; _dbSchema.Views.Add((View)currentTable); break; } } Column column = new Column { TableSchema = row["TableSchema"].ToString(), TableName = row["TableName"].ToString(), ColumnName = Config.PropertyPreFixName + row["ColumnName"].ToString(), ColumnType = row["ColumnType"].ToString(), ColumnLength = Convert.ToInt32(row["ColumnLength"], CultureInfo.InvariantCulture), ColumnIsNullable = Convert.ToBoolean(row["ColumnIsNullable"], CultureInfo.InvariantCulture), }; //Add PK/FK Info to column if (currentObjectType == DBOjectType.Table) { column.PKName = row["PKName"].ToString(); column.PKPosition = Convert.ToInt32(row["PKPosition"], CultureInfo.InvariantCulture); column.PKIsIdentity = Convert.ToBoolean(row["PKIsIdentity"], CultureInfo.InvariantCulture); column.IsComputed = Convert.ToBoolean(row["IsComputed"], CultureInfo.InvariantCulture); if (!string.IsNullOrEmpty(row["FKName"].ToString())) { AddFKColumn(row, column); } } column.DataType = _typeMapper.DBTypeToDataType(column); switch (currentObjectType) { case DBOjectType.Table: { column.Table = currentTable; currentTable.Columns.Add(column); break; } case DBOjectType.View: column.View = (View)currentTable; currentTable.Columns.Add(column); break; } _dbSchema.Columns.Add(column); return(currentTable); }