//https://sqlcetoolbox.codeplex.com/workitem/11165 public void TestSqlParse2() { string sql = "select\t\r\ncount(*) FROM Album\r\nGO"; using (IRepository repo = new DB4Repository(chinookConnectionString)) { string showPlan = string.Empty; var ds = repo.ExecuteSql(sql, out showPlan); } }
public void TestSqlParse3() { string sql = @"INSERT INTO Databases (Source, FileName, CeVersion) VALUES ('Data Source=C:\Data\SQLCE\Test\ams40.sdf', 'ams40.sdf', 1); GO "; using (IRepository repo = new DB4Repository(chinookConnectionString)) { string showPlan = string.Empty; var ds = repo.ExecuteSql(sql, out showPlan); } }
public void TestSqlParse4() { string sql = @" -- -------------------------------------------------- -- Script has ended -- -------------------------------------------------- GO"; using (IRepository repo = new DB4Repository(chinookConnectionString)) { string showPlan = string.Empty; var ds = repo.ExecuteSql(sql, out showPlan); } }
//https://sqlcetoolbox.codeplex.com/workitem/11165 public void TestSqlParse1() { string sql = @"select count(*) from Album GO "; using (IRepository repo = new DB4Repository(chinookConnectionString)) { string showPlan = string.Empty; var ds = repo.ExecuteSql(sql, out showPlan); } }
public void TestDataDiff() { string source = @"Data Source=C:\projects\ChinookPart2\Chinook40Modified.sdf"; string target = @"Data Source=C:\projects\ChinookPart2\Chinook40.sdf"; string modPath = @"C:\projects\ChinookPart2\Chinook40Modified.sdf"; if (File.Exists(modPath)) { File.Delete(modPath); } File.Copy(@"C:\projects\ChinookPart2\Chinook40.sdf", modPath); using (IRepository sourceRepository = new DB4Repository(source)) { sourceRepository.ExecuteSql("DELETE FROM InvoiceLine WHERE InvoiceLineId = 2;" + System.Environment.NewLine + "GO"); sourceRepository.ExecuteSql("DELETE FROM InvoiceLine WHERE InvoiceLineId = 3;" + System.Environment.NewLine + "GO"); sourceRepository.ExecuteSql("DELETE FROM InvoiceLine WHERE InvoiceLineId = 4;" + System.Environment.NewLine + "GO"); sourceRepository.ExecuteSql("DELETE FROM InvoiceLine WHERE InvoiceLineId = 1000;" + System.Environment.NewLine + "GO"); sourceRepository.ExecuteSql(@"INSERT INTO [InvoiceLine] ([InvoiceId],[TrackId],[UnitPrice],[Quantity]) VALUES (100, 500, 10.11, 1)" + System.Environment.NewLine + "GO"); sourceRepository.ExecuteSql(@"INSERT INTO [InvoiceLine] ([InvoiceId],[TrackId],[UnitPrice],[Quantity]) VALUES (200, 500, 10.11, 1)" + System.Environment.NewLine + "GO"); sourceRepository.ExecuteSql(@"INSERT INTO [InvoiceLine] ([InvoiceId],[TrackId],[UnitPrice],[Quantity]) VALUES (300, 500, 10.11, 1)" + System.Environment.NewLine + "GO"); sourceRepository.ExecuteSql("UPDATE InvoiceLine SET [UnitPrice]= 99.99 WHERE InvoiceLineId = 20;" + System.Environment.NewLine + "GO"); using (IRepository targetRepository = new DB4Repository(target)) { var generator = new Generator4(targetRepository); var script = SqlCeDiff.CreateDataDiffScript(sourceRepository, "InvoiceLine", targetRepository, "InvoiceLine", generator); Assert.IsTrue(script.Contains("DELETE")); } } }
public void TestSqlText() { string sql = @"-- Script Date: 13-03-2012 20:03 - Generated by ExportSqlCe version 3.5.2.7 -- Database information: -- Locale Identifier: 1030 -- Encryption Mode: -- Case Sensitive: False -- Database: C:\data\sqlce\test\nw40.sdf -- ServerVersion: 4.0.8854.1 -- DatabaseSize: 1499136 -- Created: 11-07-2010 10:46 -- User Table information: -- Number of tables: 9 -- Categories: 8 row(s) -- Customers: 91 row(s) -- ELMAH: -1 row(s) -- Employees: 15 row(s) -- Order Details: 2820 row(s) -- Orders: 1078 row(s) -- Products: 77 row(s) -- Shippers: 15 row(s) -- Suppliers: 29 row(s) SET IDENTITY_INSERT [Suppliers] ON; GO INSERT INTO [Suppliers] ([Supplier ID],[Company Name],[Contact Name],[Contact Title],[Address],[City],[Region],[Postal Code],[Country],[Phone],[Fax]) VALUES (1,N'Exotic Liquids',N'Charlotte Cooper',N'Purchasing Manager',N'49 Gilbert St.',N'London',null,N'EC1 4SD',N'UK',N'(71) 555-2222',null); GO "; using (IRepository repo = new DB4Repository(chinookConnectionString)) { string showPlan = string.Empty; var ds = repo.ExecuteSql(sql, out showPlan); Assert.IsTrue(ds.Tables.Count > 0); Assert.IsTrue(ds.Tables[0].Rows.Count > 0); } }
public void TestDataDiff() { string source = @"Data Source=C:\projects\ChinookPart2\Chinook40Modified.sdf"; string target = @"Data Source=C:\projects\ChinookPart2\Chinook40.sdf"; string modPath = @"C:\projects\ChinookPart2\Chinook40Modified.sdf"; if (File.Exists(modPath)) File.Delete(modPath); File.Copy(@"C:\projects\ChinookPart2\Chinook40.sdf", modPath); using (IRepository sourceRepository = new DB4Repository(source)) { sourceRepository.ExecuteSql("DELETE FROM InvoiceLine WHERE InvoiceLineId = 2;" + System.Environment.NewLine + "GO"); sourceRepository.ExecuteSql("DELETE FROM InvoiceLine WHERE InvoiceLineId = 3;" + System.Environment.NewLine + "GO"); sourceRepository.ExecuteSql("DELETE FROM InvoiceLine WHERE InvoiceLineId = 4;" + System.Environment.NewLine + "GO"); sourceRepository.ExecuteSql("DELETE FROM InvoiceLine WHERE InvoiceLineId = 1000;" + System.Environment.NewLine + "GO"); sourceRepository.ExecuteSql(@"INSERT INTO [InvoiceLine] ([InvoiceId],[TrackId],[UnitPrice],[Quantity]) VALUES (100, 500, 10.11, 1)" + System.Environment.NewLine + "GO"); sourceRepository.ExecuteSql(@"INSERT INTO [InvoiceLine] ([InvoiceId],[TrackId],[UnitPrice],[Quantity]) VALUES (200, 500, 10.11, 1)" + System.Environment.NewLine + "GO"); sourceRepository.ExecuteSql(@"INSERT INTO [InvoiceLine] ([InvoiceId],[TrackId],[UnitPrice],[Quantity]) VALUES (300, 500, 10.11, 1)" + System.Environment.NewLine + "GO"); sourceRepository.ExecuteSql("UPDATE InvoiceLine SET [UnitPrice]= 99.99 WHERE InvoiceLineId = 20;" + System.Environment.NewLine + "GO"); using (IRepository targetRepository = new DB4Repository(target)) { var generator = new Generator4(targetRepository); var script = SqlCeDiff.CreateDataDiffScript(sourceRepository, "InvoiceLine", targetRepository, "InvoiceLine", generator); Assert.IsTrue(script.Contains("DELETE")); } } }