diff --git a/Samples/Dapper/App.config b/Samples/Dapper/App.config index 687eeed..731e8f2 100644 --- a/Samples/Dapper/App.config +++ b/Samples/Dapper/App.config @@ -1,19 +1,6 @@  - - -
- - - - - - - - - - \ No newline at end of file diff --git a/Samples/Dapper/ElasticDapper.csproj b/Samples/Dapper/ElasticDapper.csproj index 91eedb2..e4bf855 100644 --- a/Samples/Dapper/ElasticDapper.csproj +++ b/Samples/Dapper/ElasticDapper.csproj @@ -6,10 +6,23 @@ Properties ElasticDapper ElasticDapper - v4.5 512 + + + + + + + + + Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling @@ -18,7 +31,7 @@ Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.Data - $(NugetPack)\Dapper.1.36\lib\net45\Dapper.dll + Dapper DapperExtensions diff --git a/Samples/Dapper/ElasticDapper.csproj.SamplesGallery b/Samples/Dapper/ElasticDapper.csproj.SamplesGallery new file mode 100644 index 0000000..e527bb4 --- /dev/null +++ b/Samples/Dapper/ElasticDapper.csproj.SamplesGallery @@ -0,0 +1,75 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {AF5647D3-BB21-4708-897C-0066F3677B80} + Exe + Properties + ElasticDapper + ElasticDapper + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling + + + Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.Data + + + Dapper + + + DapperExtensions + + + Microsoft.Azure.SqlDatabase.ElasticScale.Client + + + + + + + + + + + + + + + + + + + + + + + + Designer + + + + \ No newline at end of file diff --git a/Samples/Dapper/ElasticDapper.sln.SamplesGallery b/Samples/Dapper/ElasticDapper.sln.SamplesGallery new file mode 100644 index 0000000..d1e8829 --- /dev/null +++ b/Samples/Dapper/ElasticDapper.sln.SamplesGallery @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElasticDapper", "ElasticDapper\ElasticDapper.csproj", "{AF5647D3-BB21-4708-897C-0066F3677B80}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AF5647D3-BB21-4708-897C-0066F3677B80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF5647D3-BB21-4708-897C-0066F3677B80}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF5647D3-BB21-4708-897C-0066F3677B80}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF5647D3-BB21-4708-897C-0066F3677B80}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/Dapper/Program.cs b/Samples/Dapper/Program.cs index e445f9b..7ababa7 100644 --- a/Samples/Dapper/Program.cs +++ b/Samples/Dapper/Program.cs @@ -54,6 +54,12 @@ public static void Main() shardingLayer.RegisterNewShard(s_server, s_shard1, connStrBldr.ConnectionString, s_tenantId1); shardingLayer.RegisterNewShard(s_server, s_shard2, connStrBldr.ConnectionString, s_tenantId2); + // Create schema on each shard. + foreach (string shard in new[] {s_shard1, s_shard2}) + { + CreateSchema(shard); + } + // Do work for tenant 1 :-) // For tenant 1, let's stay with plain vanilla Dapper // and spell out the T-SQL we use to map into objects. @@ -70,11 +76,7 @@ public static void Main() options: ConnectionOptions.Validate)) { var blog = new Blog { Name = name }; - sqlconn.Execute(@" - INSERT INTO - Blog (Name) - VALUES (@name)", new { name = blog.Name } - ); + sqlconn.Insert(blog); } }); @@ -87,9 +89,9 @@ INSERT INTO { // Display all Blogs for tenant 1 IEnumerable result = sqlconn.Query(@" - SELECT * - FROM Blog - ORDER BY Name"); + SELECT * + FROM Blog + ORDER BY Name"); Console.WriteLine("All blogs for tenant id {0}:", s_tenantId1); foreach (var item in result) @@ -153,5 +155,29 @@ FROM Blog Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } + + private static void CreateSchema(string shardName) + { + SqlConnectionStringBuilder connStrBldr = new SqlConnectionStringBuilder + { + UserID = s_userName, + Password = s_password, + ApplicationName = s_applicationName, + DataSource = s_server, + InitialCatalog = shardName + }; + + using (SqlConnection conn = new SqlConnection(connStrBldr.ToString())) + { + conn.Open(); + conn.Execute(@" + IF (OBJECT_ID('[dbo].[Blog]', 'U') IS NULL) + CREATE TABLE [dbo].[Blog]( + [BlogId] [int] IDENTITY(1,1) PRIMARY KEY, + [Name] [nvarchar](max) NULL, + [Url] [nvarchar](max) NULL, + )"); + } + } } } diff --git a/Samples/EFCodeFirst/EntityFrameworkCodeFirst.ico b/Samples/EFCodeFirst/EntityFrameworkCodeFirst.ico deleted file mode 100644 index 7d638b1..0000000 Binary files a/Samples/EFCodeFirst/EntityFrameworkCodeFirst.ico and /dev/null differ diff --git a/Samples/EFMultiTenant/EntityFrameworkMultiTenant.ico b/Samples/EFMultiTenant/EntityFrameworkMultiTenant.ico deleted file mode 100644 index 7d638b1..0000000 Binary files a/Samples/EFMultiTenant/EntityFrameworkMultiTenant.ico and /dev/null differ diff --git a/Samples/ElasticScaleStarterKit/SampleApp.ico b/Samples/ElasticScaleStarterKit/SampleApp.ico deleted file mode 100644 index 7d638b1..0000000 Binary files a/Samples/ElasticScaleStarterKit/SampleApp.ico and /dev/null differ diff --git a/Samples/ShardSqlCmd/ShardSqlCmd.ico b/Samples/ShardSqlCmd/ShardSqlCmd.ico deleted file mode 100644 index 7d638b1..0000000 Binary files a/Samples/ShardSqlCmd/ShardSqlCmd.ico and /dev/null differ