public void Parse_Address(string dbPath, int pageID) { var db = new RawDataFile(dbPath); var page = db.GetPage(pageID); var record = page.Records.First() as RawPrimaryRecord; var result = RawColumnParser.Parse(record, new IRawType[] { RawType.Int("AddressID"), RawType.NVarchar("AddressLine1"), RawType.NVarchar("AddressLine2"), RawType.NVarchar("City"), RawType.NVarchar("StateProvince"), RawType.NVarchar("CountryRegion"), RawType.NVarchar("PostalCode"), RawType.UniqueIdentifier("rowguid"), RawType.DateTime("ModifiedDate") }); Assert.AreEqual(9, ((Dictionary <string, object>)result).Count); Assert.AreEqual(9, result.AddressID); Assert.AreEqual("8713 Yosemite Ct.", result.AddressLine1); Assert.AreEqual(null, result.AddressLine2); Assert.AreEqual("Bothell", result.City); Assert.AreEqual("Washington", result.StateProvince); Assert.AreEqual("United States", result.CountryRegion); Assert.AreEqual("98011", result.PostalCode); Assert.AreEqual(new Guid("268af621-76d7-4c78-9441-144fd139821a"), result.rowguid); Assert.AreEqual(new DateTime(2002, 07, 01), result.ModifiedDate); }
public void Parse_SalesOrderDetail(string dbPath, int pageID) { var db = new RawDataFile(dbPath); var page = db.GetPage(pageID); var record = page.Records.First() as RawPrimaryRecord; var result = RawColumnParser.Parse(record, new IRawType[] { RawType.Int("SalesOrderID"), RawType.Int("SalesOrderDetailID"), RawType.SmallInt("OrderQty"), RawType.Int("ProductID"), RawType.Money("UnitPrice"), RawType.Money("UnitPriceDiscount"), RawType.UniqueIdentifier("rowguid"), RawType.DateTime("ModifiedDate") }); Assert.AreEqual(8, ((Dictionary <string, object>)result).Count); Assert.AreEqual(71774, result.SalesOrderID); Assert.AreEqual(110562, result.SalesOrderDetailID); Assert.AreEqual(1, result.OrderQty); Assert.AreEqual(836, result.ProductID); Assert.AreEqual(356.898, result.UnitPrice); Assert.AreEqual(0.00, result.UnitPriceDiscount); Assert.AreEqual(new Guid("e3a1994c-7a68-4ce8-96a3-77fdd3bbd730"), result.rowguid); Assert.AreEqual(Convert.ToDateTime("2004-06-01"), result.ModifiedDate); }
public void Parse_SalesOrderHeader(string dbPath, int pageID, int customerID) { var db = new RawDataFile(dbPath); var page = db.GetPage(pageID); var record = page.Records.First() as RawPrimaryRecord; var result = RawColumnParser.Parse(record, new IRawType[] { RawType.Int("SalesOrderID"), RawType.TinyInt("RevisionNumber"), RawType.DateTime("OrderDate"), RawType.DateTime("DueDate"), RawType.DateTime("ShipDate"), RawType.TinyInt("Status"), RawType.Bit("OnlineOrderFlag"), RawType.NVarchar("PurchaseOrderNumber"), RawType.NVarchar("AccountNumber"), RawType.Int("CustomerID"), RawType.Int("ShipToAddressID"), RawType.Int("BillToAddressID"), RawType.NVarchar("ShipMethod"), RawType.Varchar("CreditCardApprovalCode"), RawType.Money("SubTotal"), RawType.Money("TaxAmt"), RawType.Money("Freight"), RawType.NVarchar("Comment"), RawType.UniqueIdentifier("rowguid"), RawType.DateTime("ModifiedDate") }); Assert.AreEqual(20, ((Dictionary <string, object>)result).Count); Assert.AreEqual(71774, result.SalesOrderID); Assert.AreEqual(1, result.RevisionNumber); Assert.AreEqual(Convert.ToDateTime("2004-06-01"), result.OrderDate); Assert.AreEqual(Convert.ToDateTime("2004-06-13"), result.DueDate); Assert.AreEqual(Convert.ToDateTime("2004-06-08"), result.ShipDate); Assert.AreEqual(5, result.Status); Assert.AreEqual(false, result.OnlineOrderFlag); Assert.AreEqual("PO348186287", result.PurchaseOrderNumber); Assert.AreEqual("10-4020-000609", result.AccountNumber); Assert.AreEqual(customerID, result.CustomerID); Assert.AreEqual(1092, result.ShipToAddressID); Assert.AreEqual(1092, result.BillToAddressID); Assert.AreEqual("CARGO TRANSPORT 5", result.ShipMethod); Assert.AreEqual(null, result.CreditCardApprovalCode); Assert.AreEqual(880.3484, result.SubTotal); Assert.AreEqual(70.4279, result.TaxAmt); Assert.AreEqual(22.0087, result.Freight); Assert.AreEqual(null, result.Comment); Assert.AreEqual(new Guid("89e42cdc-8506-48a2-b89b-eb3e64e3554e"), result.rowguid); Assert.AreEqual(Convert.ToDateTime("2004-06-08"), result.ModifiedDate); }
public void Parse_Product(string dbPath, int pageID) { var db = new RawDataFile(dbPath); var page = db.GetPage(pageID); var record = page.Records.First() as RawPrimaryRecord; var result = RawColumnParser.Parse(record, new IRawType[] { RawType.Int("ProductID"), RawType.NVarchar("Name"), RawType.NVarchar("ProductNumber"), RawType.NVarchar("Color"), RawType.Money("StandardCost"), RawType.Money("ListPrice"), RawType.NVarchar("Size"), RawType.Decimal("Weight", 8, 2), RawType.Int("ProductCategoryID"), RawType.Int("ProductModelID"), RawType.DateTime("SellStartDate"), RawType.DateTime("SellEndDate"), RawType.DateTime("DiscontinuedDate"), RawType.VarBinary("ThumbNailPhoto"), RawType.NVarchar("ThumbnailPhotoFileName"), RawType.UniqueIdentifier("rowguid"), RawType.DateTime("ModifiedDate") }); Assert.AreEqual(17, ((Dictionary <string, object>)result).Count); Assert.AreEqual(680, result.ProductID); Assert.AreEqual("HL Road Frame - Black, 58", result.Name); Assert.AreEqual("FR-R92B-58", result.ProductNumber); Assert.AreEqual("Black", result.Color); Assert.AreEqual(1059.31, result.StandardCost); Assert.AreEqual(1431.50, result.ListPrice); Assert.AreEqual("58", result.Size); Assert.AreEqual(1016.04, result.Weight); Assert.AreEqual(18, result.ProductCategoryID); Assert.AreEqual(6, result.ProductModelID); Assert.AreEqual(Convert.ToDateTime("1998-06-01"), result.SellStartDate); Assert.AreEqual(null, result.SellEndDate); Assert.AreEqual(null, result.DiscontinuedDate); Assert.AreEqual(1077, result.ThumbNailPhoto.Length); Assert.AreEqual("no_image_available_small.gif", result.ThumbnailPhotoFileName); Assert.AreEqual(new Guid("43dd68d6-14a4-461f-9069-55309d90ea7e"), result.rowguid); Assert.AreEqual(Convert.ToDateTime("2004-03-11 10:01:36.827"), result.ModifiedDate); }
public void Parse_ProductDescription(string dbPath, int pageID) { var db = new RawDataFile(dbPath); var page = db.GetPage(pageID); var record = page.Records.First() as RawPrimaryRecord; var result = RawColumnParser.Parse(record, new IRawType[] { RawType.Int("ProductDescriptionID"), RawType.NVarchar("Description"), RawType.UniqueIdentifier("rowguid"), RawType.DateTime("ModifiedDate") }); Assert.AreEqual(4, ((Dictionary <string, object>)result).Count); Assert.AreEqual(3, result.ProductDescriptionID); Assert.AreEqual("Chromoly steel.", result.Description); Assert.AreEqual(new Guid("301eed3a-1a82-4855-99cb-2afe8290d641"), result.rowguid); Assert.AreEqual(Convert.ToDateTime("2003-06-01"), result.ModifiedDate); }
public void Parse_Customer(string dbPath, int pageID, string modifiedDate) { var db = new RawDataFile(dbPath); var page = db.GetPage(pageID); var record = page.Records.First() as RawPrimaryRecord; var result = RawColumnParser.Parse(record, new IRawType[] { RawType.Int("CustomerID"), RawType.Bit("NameStyle"), RawType.NVarchar("Title"), RawType.NVarchar("FirstName"), RawType.NVarchar("MiddleName"), RawType.NVarchar("LastName"), RawType.NVarchar("Suffix"), RawType.NVarchar("CompanyName"), RawType.NVarchar("SalesPerson"), RawType.NVarchar("EmailAddress"), RawType.NVarchar("Phone"), RawType.Varchar("PasswordHash"), RawType.Varchar("PasswordSalt"), RawType.UniqueIdentifier("rowguid"), RawType.DateTime("ModifiedDate") }); Assert.AreEqual(15, ((Dictionary <string, object>)result).Count); Assert.AreEqual(1, result.CustomerID); Assert.AreEqual(false, result.NameStyle); Assert.AreEqual("Mr.", result.Title); Assert.AreEqual("Orlando", result.FirstName); Assert.AreEqual("N.", result.MiddleName); Assert.AreEqual("Gee", result.LastName); Assert.AreEqual(null, result.Suffix); Assert.AreEqual("A Bike Store", result.CompanyName); Assert.AreEqual(@"adventure-works\pamela0", result.SalesPerson); Assert.AreEqual("*****@*****.**", result.EmailAddress); Assert.AreEqual("245-555-0173", result.Phone); Assert.AreEqual("L/Rlwxzp4w7RWmEgXX+/A7cXaePEPcp+KwQhl2fJL7w=", result.PasswordHash); Assert.AreEqual("1KjXYs4=", result.PasswordSalt); Assert.AreEqual(new Guid("3f5ae95e-b87d-4aed-95b4-c3797afcb74f"), result.rowguid); Assert.AreEqual(Convert.ToDateTime(modifiedDate), result.ModifiedDate); }
public void Parse_ProductModelProductDescription(string dbPath, int pageID, string rowguid) { var db = new RawDataFile(dbPath); var page = db.GetPage(pageID); var record = page.Records.First() as RawPrimaryRecord; var result = RawColumnParser.Parse(record, new IRawType[] { RawType.Int("ProductModelID"), RawType.Int("ProductDescriptionID"), RawType.NChar("Culture", 6), RawType.UniqueIdentifier("rowguid"), RawType.DateTime("ModifiedDate") }); Assert.AreEqual(5, ((Dictionary <string, object>)result).Count); Assert.AreEqual(1, result.ProductModelID); Assert.AreEqual(1199, result.ProductDescriptionID); Assert.AreEqual("en".PadRight(6, ' '), result.Culture); Assert.AreEqual(new Guid(rowguid), result.rowguid); Assert.AreEqual(Convert.ToDateTime("2003-06-01"), result.ModifiedDate); }
public void Parse_ProductModel(string dbPath, int pageID) { var db = new RawDataFile(dbPath); var page = db.GetPage(pageID); var record = page.Records.First() as RawPrimaryRecord; var result = RawColumnParser.Parse(record, new IRawType[] { RawType.Int("ProductModelID"), RawType.NVarchar("Name"), RawType.Xml("CatalogDescription"), RawType.UniqueIdentifier("rowguid"), RawType.DateTime("ModifiedDate") }); Assert.AreEqual(5, ((Dictionary <string, object>)result).Count); Assert.AreEqual(1, result.ProductModelID); Assert.AreEqual("Classic Vest", result.Name); Assert.AreEqual(null, result.CatalogDescription); Assert.AreEqual(new Guid("29321d47-1e4c-4aac-887c-19634328c25e"), result.rowguid); Assert.AreEqual(Convert.ToDateTime("2003-06-01"), result.ModifiedDate); }
public void Parse_ProductCategory(string dbPath, int pageID) { var db = new RawDataFile(dbPath); var page = db.GetPage(pageID); var record = page.Records.First() as RawPrimaryRecord; var result = RawColumnParser.Parse(record, new IRawType[] { RawType.Int("ProductCategoryID"), RawType.Int("ParentProductCategoryID"), RawType.NVarchar("Name"), RawType.UniqueIdentifier("rowguid"), RawType.DateTime("ModifiedDate") }); Assert.AreEqual(5, ((Dictionary <string, object>)result).Count); Assert.AreEqual(1, result.ProductCategoryID); Assert.AreEqual(null, result.ParentProductCategoryID); Assert.AreEqual("Bikes", result.Name); Assert.AreEqual(new Guid("cfbda25c-df71-47a7-b81b-64ee161aa37c"), result.rowguid); Assert.AreEqual(Convert.ToDateTime("1998-06-01"), result.ModifiedDate); }
public void Parse_CustomerAddress(string dbPath, int pageID, int customerID, int addressID, string rowguid, string modifiedDate) { var db = new RawDataFile(dbPath); var page = db.GetPage(pageID); var record = page.Records.First() as RawPrimaryRecord; var result = RawColumnParser.Parse(record, new IRawType[] { RawType.Int("CustomerID"), RawType.Int("AddressID"), RawType.NVarchar("AddressType"), RawType.UniqueIdentifier("rowguid"), RawType.DateTime("ModifiedDate") }); Assert.AreEqual(5, ((Dictionary <string, object>)result).Count); Assert.AreEqual(customerID, result.CustomerID); Assert.AreEqual(addressID, result.AddressID); Assert.AreEqual("Main Office", result.AddressType); Assert.AreEqual(new Guid(rowguid), result.rowguid); Assert.AreEqual(Convert.ToDateTime(modifiedDate), result.ModifiedDate); }
private void rawaddTablesNode(TreeNode rootNode) { var tableRootNode = rootNode.Nodes.Add("Tables"); var tables = rawtables.OrderBy(t => t.Name); foreach (var t in tables) { var tableNode = tableRootNode.Nodes.Add(t.Name); tableNode.ContextMenu = tableMenu; logException(null, "Tabla: [" + t.Name + "]"); // Add columns var tableColumnsNode = tableNode.Nodes.Add("Columns"); var columns = rawcolumns .Where(c => c.ObjectID == t.id) .OrderBy(c => c.Name); rawcolumnType[] rawcolumntypes = new rawcolumnType[30]; rawcolumntypes[0] = new rawcolumnType("image", 34, 16); rawcolumntypes[1] = new rawcolumnType("text", 35, 16); rawcolumntypes[2] = new rawcolumnType("uniqueidentifier", 36, 16); rawcolumntypes[3] = new rawcolumnType("date", 40, 3); rawcolumntypes[4] = new rawcolumnType("time", 41, 5); rawcolumntypes[5] = new rawcolumnType("datetime2", 42, 8); rawcolumntypes[6] = new rawcolumnType("datetimeoffset", 43, 10); rawcolumntypes[7] = new rawcolumnType("tinyint", 48, 1); rawcolumntypes[8] = new rawcolumnType("smallint", 52, 2); rawcolumntypes[9] = new rawcolumnType("int", 56, 4); rawcolumntypes[10] = new rawcolumnType("smalldatetime", 58, 4); rawcolumntypes[11] = new rawcolumnType("real", 59, 4); rawcolumntypes[12] = new rawcolumnType("money", 60, 8); rawcolumntypes[13] = new rawcolumnType("datetime", 61, 8); rawcolumntypes[14] = new rawcolumnType("float", 62, 8); rawcolumntypes[15] = new rawcolumnType("sql_variant", 98, 8016); rawcolumntypes[16] = new rawcolumnType("ntext", 99, 16); rawcolumntypes[17] = new rawcolumnType("bit", 104, 1); rawcolumntypes[18] = new rawcolumnType("decimal", 106, 17); rawcolumntypes[19] = new rawcolumnType("numeric", 108, 17); rawcolumntypes[20] = new rawcolumnType("smallmoney", 122, 4); rawcolumntypes[21] = new rawcolumnType("bigint", 127, 8); rawcolumntypes[22] = new rawcolumnType("varbinary", 165, 8000); rawcolumntypes[23] = new rawcolumnType("varchar", 167, 8000); rawcolumntypes[24] = new rawcolumnType("binary", 173, 8000); rawcolumntypes[25] = new rawcolumnType("char", 175, 8000); rawcolumntypes[26] = new rawcolumnType("timestamp", 189, 8); rawcolumntypes[27] = new rawcolumnType("nvarchar", 231, 8000); rawcolumntypes[28] = new rawcolumnType("nchar", 239, 8000); rawcolumntypes[29] = new rawcolumnType("xml", 241, -1); foreach (var c in columns) { try { var mainColumn = columns.Where(x => x.ColumnID == c.ColumnID && x.ObjectID == c.ObjectID).First(); var type = rawcolumntypes.Where(x => x.col_System_type_id == mainColumn.TypeID).First(); tableColumnsNode.Nodes.Add(c.Name + " (" + type.columnName + "[" + type.max_Length + "])"); logException(null, "Column: [" + t.Name + "]." + "[" + c.Name + "]"); } catch (Exception ex) { logException(ex, "Table: " + t.Name + " Column: " + c.Name + " ColumnID: " + c.ColumnID + " ObjectID: " + c.ObjectID); } } try { var unorderedcolumns = rawcolumns .Where(c => c.ObjectID == t.id); IRawType[] SchemaRawType = new IRawType[] { }; var unorderedFirstColumn = unorderedcolumns.First(); Boolean firstColumn = true; var unorderedFirstColumntype = rawcolumntypes.Where(x => x.col_System_type_id == unorderedFirstColumn.TypeID).First(); Array.Resize(ref SchemaRawType, 1); switch (unorderedFirstColumntype.col_System_type_id) { case 34: SchemaRawType[0] = RawType.Binary(unorderedFirstColumn.Name, unorderedFirstColumn.Length); break; case 35: SchemaRawType[0] = RawType.Binary(unorderedFirstColumn.Name, unorderedFirstColumn.Length); break; case 36: SchemaRawType[0] = RawType.UniqueIdentifier(unorderedFirstColumn.Name); break; case 40: SchemaRawType[0] = RawType.Date(unorderedFirstColumn.Name); break; case 41: SchemaRawType[0] = RawType.DateTime(unorderedFirstColumn.Name); break; case 42: SchemaRawType[0] = RawType.DateTime(unorderedFirstColumn.Name); break; case 43: SchemaRawType[0] = RawType.DateTime(unorderedFirstColumn.Name); break; case 48: SchemaRawType[0] = RawType.TinyInt(unorderedFirstColumn.Name); break; case 52: SchemaRawType[0] = RawType.SmallInt(unorderedFirstColumn.Name); break; case 56: SchemaRawType[0] = RawType.Int(unorderedFirstColumn.Name); break; case 58: SchemaRawType[0] = RawType.DateTime(unorderedFirstColumn.Name); break; case 59: SchemaRawType[0] = RawType.Decimal(unorderedFirstColumn.Name, Convert.ToByte(15), Convert.ToByte(2)); break; case 60: SchemaRawType[0] = RawType.Money(unorderedFirstColumn.Name); break; case 61: SchemaRawType[0] = RawType.DateTime(unorderedFirstColumn.Name); break; case 62: if (unorderedFirstColumn.Length <= 24) { SchemaRawType[0] = RawType.Decimal(unorderedFirstColumn.Name, Convert.ToByte(7), Convert.ToByte(2)); } else { SchemaRawType[0] = RawType.Decimal(unorderedFirstColumn.Name, Convert.ToByte(15), Convert.ToByte(2)); } break; case 98: SchemaRawType[0] = RawType.Binary(unorderedFirstColumn.Name, unorderedFirstColumn.Length); break; case 99: SchemaRawType[0] = RawType.Binary(unorderedFirstColumn.Name, unorderedFirstColumn.Length); break; case 104: SchemaRawType[0] = RawType.Bit(unorderedFirstColumn.Name); break; case 106: SchemaRawType[0] = RawType.Decimal(unorderedFirstColumn.Name, Convert.ToByte(28), Convert.ToByte(6)); break; case 108: SchemaRawType[0] = RawType.Decimal(unorderedFirstColumn.Name, Convert.ToByte(28), Convert.ToByte(6)); break; case 122: SchemaRawType[0] = RawType.Money(unorderedFirstColumn.Name); break; case 127: SchemaRawType[0] = RawType.BigInt(unorderedFirstColumn.Name); break; case 165: SchemaRawType[0] = RawType.VarBinary(unorderedFirstColumn.Name); break; case 167: SchemaRawType[0] = RawType.Varchar(unorderedFirstColumn.Name); break; case 173: SchemaRawType[0] = RawType.Binary(unorderedFirstColumn.Name, unorderedFirstColumn.Length); break; case 175: SchemaRawType[0] = RawType.Char(unorderedFirstColumn.Name, unorderedFirstColumn.Length); break; case 189: SchemaRawType[0] = RawType.Binary(unorderedFirstColumn.Name, unorderedFirstColumn.Length); break; case 231: SchemaRawType[0] = RawType.NVarchar(unorderedFirstColumn.Name); break; case 239: SchemaRawType[0] = RawType.NChar(unorderedFirstColumn.Name, unorderedFirstColumn.Length); break; case 241: SchemaRawType[0] = RawType.Xml(unorderedFirstColumn.Name); break; default: SchemaRawType[0] = RawType.VarBinary(unorderedFirstColumn.Name); break; } logException(null, "Column: [" + t.Name + "]." + "[" + unorderedFirstColumn.Name + "]"); int i = 1; foreach (var c in unorderedcolumns) { if (firstColumn != true) { try { var nextColumn = unorderedcolumns.Where(x => x.ColumnID == c.ColumnID && x.ObjectID == c.ObjectID).First(); var type = rawcolumntypes.Where(x => x.col_System_type_id == c.TypeID).First(); Array.Resize(ref SchemaRawType, i + 1); SchemaRawType[i] = new RawNVarchar(""); Boolean uniqueColumn; try { uniqueColumn = (SchemaRawType.Where(x => x.Name.StartsWith(nextColumn.Name)).Count() == 0); } catch (Exception ex) { logException(ex, "Column: [" + t.Name + "].[" + c.Name + "]"); uniqueColumn = true; } if (uniqueColumn) { switch (type.col_System_type_id) { case 34: SchemaRawType[i] = RawType.Binary(nextColumn.Name, nextColumn.Length); break; case 35: SchemaRawType[i] = RawType.Binary(nextColumn.Name, nextColumn.Length); break; case 36: SchemaRawType[i] = RawType.UniqueIdentifier(nextColumn.Name); break; case 40: SchemaRawType[i] = RawType.Date(nextColumn.Name); break; case 41: SchemaRawType[i] = RawType.DateTime(nextColumn.Name); break; case 42: SchemaRawType[i] = RawType.DateTime(nextColumn.Name); break; case 43: SchemaRawType[i] = RawType.DateTime(nextColumn.Name); break; case 48: SchemaRawType[i] = RawType.TinyInt(nextColumn.Name); break; case 52: SchemaRawType[i] = RawType.SmallInt(nextColumn.Name); break; case 56: SchemaRawType[i] = RawType.Int(nextColumn.Name); break; case 58: SchemaRawType[i] = RawType.DateTime(nextColumn.Name); break; case 59: SchemaRawType[i] = RawType.Decimal(nextColumn.Name, Convert.ToByte(15), Convert.ToByte(2)); break; case 60: SchemaRawType[i] = RawType.Money(nextColumn.Name); break; case 61: SchemaRawType[i] = RawType.DateTime(nextColumn.Name); break; case 62: if (nextColumn.Length <= 24) { SchemaRawType[i] = RawType.Decimal(nextColumn.Name, Convert.ToByte(7), Convert.ToByte(2)); } else { SchemaRawType[i] = RawType.Decimal(nextColumn.Name, Convert.ToByte(15), Convert.ToByte(2)); } break; case 98: SchemaRawType[i] = RawType.Binary(nextColumn.Name, nextColumn.Length); break; case 99: SchemaRawType[i] = RawType.Binary(nextColumn.Name, nextColumn.Length); break; case 104: SchemaRawType[i] = RawType.Bit(nextColumn.Name); break; case 106: SchemaRawType[i] = RawType.Decimal(nextColumn.Name, Convert.ToByte(28), Convert.ToByte(6)); break; case 108: SchemaRawType[i] = RawType.Decimal(nextColumn.Name, Convert.ToByte(28), Convert.ToByte(6)); break; case 122: SchemaRawType[i] = RawType.Money(nextColumn.Name); break; case 127: SchemaRawType[i] = RawType.BigInt(nextColumn.Name); break; case 165: SchemaRawType[i] = RawType.VarBinary(nextColumn.Name); break; case 167: SchemaRawType[i] = RawType.Varchar(nextColumn.Name); break; case 173: SchemaRawType[i] = RawType.Binary(nextColumn.Name, nextColumn.Length); break; case 175: SchemaRawType[i] = RawType.Char(nextColumn.Name, nextColumn.Length); break; case 189: SchemaRawType[i] = RawType.Binary(nextColumn.Name, nextColumn.Length); break; case 231: SchemaRawType[i] = RawType.NVarchar(nextColumn.Name); break; case 239: SchemaRawType[i] = RawType.NChar(nextColumn.Name, nextColumn.Length); break; case 241: SchemaRawType[i] = RawType.Xml(nextColumn.Name); break; default: SchemaRawType[i] = RawType.VarBinary(unorderedFirstColumn.Name); break; } i = i + 1; logException(null, "Column: [" + t.Name + "]." + "[" + nextColumn.Name + "]"); } } catch (Exception ex) { logException(ex, "Column: [" + t.Name + "].[" + c.Name + "]"); } } else { firstColumn = false; } } RawTablesSchemas.Add(t.Name, SchemaRawType); } catch (Exception ex) { logException(ex, "Table: " + t.name + ". Failed to get schema"); } // Add indexes // var tableIndexesNode = tableNode.Nodes.Add("Indexes"); // var indexes = db.Dmvs.Indexes // .Where(i => i.ObjectID == t.ObjectID && i.IndexID > 0) // .OrderBy(i => i.Name); // foreach (var i in indexes) // { // var indexNode = tableIndexesNode.Nodes.Add(i.Name); // Add index columns // var indexColumns = db.Dmvs.IndexColumns // .Where(ic => ic.ObjectID == t.ObjectID && ic.IndexID == i.IndexID); // foreach (var ic in indexColumns) // { // var mainColumn = db.Dmvs.Columns.Where(x => x.ColumnID == ic.ColumnID && x.ObjectID == ic.ObjectID).Single(); // var type = db.Dmvs.Types.Where(x => x.SystemTypeID == mainColumn.SystemTypeID).First(); // indexNode.Nodes.Add(columns.Where(c => c.ColumnID == ic.ColumnID).Single().Name + " (" + type.Name + "[" + type.MaxLength + "])"); // } } }