using System.Data; using System.Text; using Connected.Data.Schema; namespace Connected.ServiceModel.Client.Data.Schema; internal class TableTransaction : SynchronizationTransaction { protected static string CreateColumnCommandText(ISchemaColumn column) { var builder = new StringBuilder(); builder.AppendFormat($"{column.Name} {CreateDataTypeMetaData(column)} "); return builder.ToString(); } protected static string CreateDataTypeMetaData(ISchemaColumn column) { return column.DataType switch { DbType.AnsiString => "text", DbType.Binary => "blob", DbType.Byte => "tinyint", DbType.Boolean => "boolean", DbType.Currency => "decimal", DbType.Date => "timestamp", DbType.DateTime => "timestamp", DbType.Decimal => "decimal", DbType.Double => "double", DbType.Guid => "uuid", DbType.Int16 => "smallint", DbType.Int32 => "int", DbType.Int64 => "bigint", DbType.Object => "blob", DbType.SByte => "smallint", DbType.Single => "float", DbType.String => "text", DbType.Time => "time", DbType.UInt16 => "int", DbType.UInt32 => "bigint", DbType.UInt64 => "float", DbType.VarNumeric => "decimal", DbType.AnsiStringFixedLength => "text", DbType.StringFixedLength => "text", DbType.Xml => "text", DbType.DateTime2 => "timestamp", DbType.DateTimeOffset => "timestamp", _ => throw new NotSupportedException(), }; } }