From aed4fda91cd17bccf13291412fb21db338e02ddb Mon Sep 17 00:00:00 2001 From: Jared Moore Date: Fri, 28 Aug 2015 17:14:33 -0700 Subject: [PATCH 1/5] Enabled samples gallery build for Dapper sample. Fixes #34 --- Samples/Dapper/ElasticDapper.csproj | 17 ++++- .../ElasticDapper.csproj.SamplesGallery | 75 +++++++++++++++++++ .../Dapper/ElasticDapper.sln.SamplesGallery | 20 +++++ 3 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 Samples/Dapper/ElasticDapper.csproj.SamplesGallery create mode 100644 Samples/Dapper/ElasticDapper.sln.SamplesGallery 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 From dd715fd2800cd5772cfa8e60cbfa2f0dcf1de44a Mon Sep 17 00:00:00 2001 From: Jared Moore Date: Fri, 28 Aug 2015 22:22:02 -0700 Subject: [PATCH 2/5] Removed unused .ico files from samples Fixes #36 --- .../EFCodeFirst/EntityFrameworkCodeFirst.ico | Bin 10134 -> 0 bytes .../EntityFrameworkMultiTenant.ico | Bin 10134 -> 0 bytes Samples/ElasticScaleStarterKit/SampleApp.ico | Bin 10134 -> 0 bytes Samples/ShardSqlCmd/ShardSqlCmd.ico | Bin 10134 -> 0 bytes 4 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Samples/EFCodeFirst/EntityFrameworkCodeFirst.ico delete mode 100644 Samples/EFMultiTenant/EntityFrameworkMultiTenant.ico delete mode 100644 Samples/ElasticScaleStarterKit/SampleApp.ico delete mode 100644 Samples/ShardSqlCmd/ShardSqlCmd.ico diff --git a/Samples/EFCodeFirst/EntityFrameworkCodeFirst.ico b/Samples/EFCodeFirst/EntityFrameworkCodeFirst.ico deleted file mode 100644 index 7d638b1d6002bdeac28d672a833d2f55dc18a491..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10134 zcmeHNy>8nu5I*@Y%1}7y0~7|jWa=w4$e!-mgCb8*catV(H1ZbNvj<-D78%;2K$cEP zGqK;1I*B@ww&K5}f$5x%$B%d4kzy%YE>S`Q8jTL1d-S_Q^p%JX4xD|M5Pj(qZ~~sv zRZ8@&$GEf4`$Qk!2|l7Lv`^j(KB9B<{q&LO5HS&gjv&lq3%J51C&C})xl_2J3dw0U zn*lKPkBs3O1Rril-T&Bi24Ee+>m2_C>{^#~p2H589E%zV*0oi*qS|_$|A8ytJ*|0$x!q)0_Bej@ z7g096aEoQ=7D-lUQ`!ZN`wH(YqhWDhht{m@4CErH`Xz^EYqQb=qBbGq9V1H#Gy;c_?j^`Vbp% zv6V=#G)-zH-4H$)IGR}e3fCFe(n~bj%%58-5xmQ|l*C8AqaM7WO$6H+d z`8e4-*zY7sryuHR@xIGF)WPEL=F(9Cn4j@I2RG7Lgmbug@k>0CpTzH_;qeKs(yp17 zzt&PW80R=KX@l1z)~(miA3Do%+x#*Eybd`;oa#JRY#znA1duzUc;}RplM^~SJF{n% z%gal9R=K^swda(lrzh*OyX3S`N)B7g z3~hIw@IE_&96=IWgAZ@Ks^I&cS%;{wt<80CbBxx6s-y7ZJF!_t#9xJNZHoUg-0UO% ztqD~}@qexScrRgCV);q_YFMpJ@sGuC%P(=3)iM4>?aT6MzePMTJQhdV#V=;-cIht~ z@2Cum*jkIfXu;dsx}W&7W?sQ#IS9V0_IWk8#17>k*#DwsoG+EH=9i5^=Yw~m2JcAA zb;osX)BRSpL;TDmd1}4x976p5xHUgxtBhIVNes=8chJ$XYhQ`+9Iaz)n_uUu`5E8j z{I}uX*W=#? zr_Z7JH+{c#{MW|s&&@XKdi>kq^f|)6?Z4Ff;E|nHQQ}C z3;)tr^5z)x{DmKVM%+*Qd_B)!uvPhG{CtM-$KUo$!~R^5&s1_^jo(J>_+^|i?Y!O9 h_itO*{xP0dyY_F(EB(s<8#Cv9D0Ae6%%JZ)`3E-S-Xj12 diff --git a/Samples/EFMultiTenant/EntityFrameworkMultiTenant.ico b/Samples/EFMultiTenant/EntityFrameworkMultiTenant.ico deleted file mode 100644 index 7d638b1d6002bdeac28d672a833d2f55dc18a491..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10134 zcmeHNy>8nu5I*@Y%1}7y0~7|jWa=w4$e!-mgCb8*catV(H1ZbNvj<-D78%;2K$cEP zGqK;1I*B@ww&K5}f$5x%$B%d4kzy%YE>S`Q8jTL1d-S_Q^p%JX4xD|M5Pj(qZ~~sv zRZ8@&$GEf4`$Qk!2|l7Lv`^j(KB9B<{q&LO5HS&gjv&lq3%J51C&C})xl_2J3dw0U zn*lKPkBs3O1Rril-T&Bi24Ee+>m2_C>{^#~p2H589E%zV*0oi*qS|_$|A8ytJ*|0$x!q)0_Bej@ z7g096aEoQ=7D-lUQ`!ZN`wH(YqhWDhht{m@4CErH`Xz^EYqQb=qBbGq9V1H#Gy;c_?j^`Vbp% zv6V=#G)-zH-4H$)IGR}e3fCFe(n~bj%%58-5xmQ|l*C8AqaM7WO$6H+d z`8e4-*zY7sryuHR@xIGF)WPEL=F(9Cn4j@I2RG7Lgmbug@k>0CpTzH_;qeKs(yp17 zzt&PW80R=KX@l1z)~(miA3Do%+x#*Eybd`;oa#JRY#znA1duzUc;}RplM^~SJF{n% z%gal9R=K^swda(lrzh*OyX3S`N)B7g z3~hIw@IE_&96=IWgAZ@Ks^I&cS%;{wt<80CbBxx6s-y7ZJF!_t#9xJNZHoUg-0UO% ztqD~}@qexScrRgCV);q_YFMpJ@sGuC%P(=3)iM4>?aT6MzePMTJQhdV#V=;-cIht~ z@2Cum*jkIfXu;dsx}W&7W?sQ#IS9V0_IWk8#17>k*#DwsoG+EH=9i5^=Yw~m2JcAA zb;osX)BRSpL;TDmd1}4x976p5xHUgxtBhIVNes=8chJ$XYhQ`+9Iaz)n_uUu`5E8j z{I}uX*W=#? zr_Z7JH+{c#{MW|s&&@XKdi>kq^f|)6?Z4Ff;E|nHQQ}C z3;)tr^5z)x{DmKVM%+*Qd_B)!uvPhG{CtM-$KUo$!~R^5&s1_^jo(J>_+^|i?Y!O9 h_itO*{xP0dyY_F(EB(s<8#Cv9D0Ae6%%JZ)`3E-S-Xj12 diff --git a/Samples/ElasticScaleStarterKit/SampleApp.ico b/Samples/ElasticScaleStarterKit/SampleApp.ico deleted file mode 100644 index 7d638b1d6002bdeac28d672a833d2f55dc18a491..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10134 zcmeHNy>8nu5I*@Y%1}7y0~7|jWa=w4$e!-mgCb8*catV(H1ZbNvj<-D78%;2K$cEP zGqK;1I*B@ww&K5}f$5x%$B%d4kzy%YE>S`Q8jTL1d-S_Q^p%JX4xD|M5Pj(qZ~~sv zRZ8@&$GEf4`$Qk!2|l7Lv`^j(KB9B<{q&LO5HS&gjv&lq3%J51C&C})xl_2J3dw0U zn*lKPkBs3O1Rril-T&Bi24Ee+>m2_C>{^#~p2H589E%zV*0oi*qS|_$|A8ytJ*|0$x!q)0_Bej@ z7g096aEoQ=7D-lUQ`!ZN`wH(YqhWDhht{m@4CErH`Xz^EYqQb=qBbGq9V1H#Gy;c_?j^`Vbp% zv6V=#G)-zH-4H$)IGR}e3fCFe(n~bj%%58-5xmQ|l*C8AqaM7WO$6H+d z`8e4-*zY7sryuHR@xIGF)WPEL=F(9Cn4j@I2RG7Lgmbug@k>0CpTzH_;qeKs(yp17 zzt&PW80R=KX@l1z)~(miA3Do%+x#*Eybd`;oa#JRY#znA1duzUc;}RplM^~SJF{n% z%gal9R=K^swda(lrzh*OyX3S`N)B7g z3~hIw@IE_&96=IWgAZ@Ks^I&cS%;{wt<80CbBxx6s-y7ZJF!_t#9xJNZHoUg-0UO% ztqD~}@qexScrRgCV);q_YFMpJ@sGuC%P(=3)iM4>?aT6MzePMTJQhdV#V=;-cIht~ z@2Cum*jkIfXu;dsx}W&7W?sQ#IS9V0_IWk8#17>k*#DwsoG+EH=9i5^=Yw~m2JcAA zb;osX)BRSpL;TDmd1}4x976p5xHUgxtBhIVNes=8chJ$XYhQ`+9Iaz)n_uUu`5E8j z{I}uX*W=#? zr_Z7JH+{c#{MW|s&&@XKdi>kq^f|)6?Z4Ff;E|nHQQ}C z3;)tr^5z)x{DmKVM%+*Qd_B)!uvPhG{CtM-$KUo$!~R^5&s1_^jo(J>_+^|i?Y!O9 h_itO*{xP0dyY_F(EB(s<8#Cv9D0Ae6%%JZ)`3E-S-Xj12 diff --git a/Samples/ShardSqlCmd/ShardSqlCmd.ico b/Samples/ShardSqlCmd/ShardSqlCmd.ico deleted file mode 100644 index 7d638b1d6002bdeac28d672a833d2f55dc18a491..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10134 zcmeHNy>8nu5I*@Y%1}7y0~7|jWa=w4$e!-mgCb8*catV(H1ZbNvj<-D78%;2K$cEP zGqK;1I*B@ww&K5}f$5x%$B%d4kzy%YE>S`Q8jTL1d-S_Q^p%JX4xD|M5Pj(qZ~~sv zRZ8@&$GEf4`$Qk!2|l7Lv`^j(KB9B<{q&LO5HS&gjv&lq3%J51C&C})xl_2J3dw0U zn*lKPkBs3O1Rril-T&Bi24Ee+>m2_C>{^#~p2H589E%zV*0oi*qS|_$|A8ytJ*|0$x!q)0_Bej@ z7g096aEoQ=7D-lUQ`!ZN`wH(YqhWDhht{m@4CErH`Xz^EYqQb=qBbGq9V1H#Gy;c_?j^`Vbp% zv6V=#G)-zH-4H$)IGR}e3fCFe(n~bj%%58-5xmQ|l*C8AqaM7WO$6H+d z`8e4-*zY7sryuHR@xIGF)WPEL=F(9Cn4j@I2RG7Lgmbug@k>0CpTzH_;qeKs(yp17 zzt&PW80R=KX@l1z)~(miA3Do%+x#*Eybd`;oa#JRY#znA1duzUc;}RplM^~SJF{n% z%gal9R=K^swda(lrzh*OyX3S`N)B7g z3~hIw@IE_&96=IWgAZ@Ks^I&cS%;{wt<80CbBxx6s-y7ZJF!_t#9xJNZHoUg-0UO% ztqD~}@qexScrRgCV);q_YFMpJ@sGuC%P(=3)iM4>?aT6MzePMTJQhdV#V=;-cIht~ z@2Cum*jkIfXu;dsx}W&7W?sQ#IS9V0_IWk8#17>k*#DwsoG+EH=9i5^=Yw~m2JcAA zb;osX)BRSpL;TDmd1}4x976p5xHUgxtBhIVNes=8chJ$XYhQ`+9Iaz)n_uUu`5E8j z{I}uX*W=#? zr_Z7JH+{c#{MW|s&&@XKdi>kq^f|)6?Z4Ff;E|nHQQ}C z3;)tr^5z)x{DmKVM%+*Qd_B)!uvPhG{CtM-$KUo$!~R^5&s1_^jo(J>_+^|i?Y!O9 h_itO*{xP0dyY_F(EB(s<8#Cv9D0Ae6%%JZ)`3E-S-Xj12 From 646e6daa5a59aa8d21e7e00020f0478400031958 Mon Sep 17 00:00:00 2001 From: Jared Moore Date: Fri, 28 Aug 2015 22:41:13 -0700 Subject: [PATCH 3/5] Cleanup app.config for Dapper sample Fixes #35 --- Samples/Dapper/App.config | 13 ------------- 1 file changed, 13 deletions(-) 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 From 937bbd2124bfdadf9ef6219655826d7505b4b905 Mon Sep 17 00:00:00 2001 From: Jared Moore Date: Sat, 29 Aug 2015 18:12:43 -0700 Subject: [PATCH 4/5] Add create schema code to ElasticDapper sample. The dapper sample doesn't work straight away out of the box. I get "Invalid object name 'Blog'." because the Blog table is not created. The sample should be able to set itself up in order to minimize friction. Fixes #37 --- Samples/Dapper/Program.cs | 44 ++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/Samples/Dapper/Program.cs b/Samples/Dapper/Program.cs index e445f9b..b95d01c 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. @@ -71,10 +77,10 @@ public static void Main() { var blog = new Blog { Name = name }; sqlconn.Execute(@" - INSERT INTO - Blog (Name) - VALUES (@name)", new { name = blog.Name } - ); + INSERT INTO + Blog (Name) + VALUES (@name)", + new {name = blog.Name}); } }); @@ -87,9 +93,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 +159,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, + )"); + } + } } } From 7a954a6855292e339f4ca6a2d3227aa8627d7176 Mon Sep 17 00:00:00 2001 From: Jared Moore Date: Sat, 29 Aug 2015 19:33:16 -0700 Subject: [PATCH 5/5] Changed ElasticDapper sample to use Dapper more idiomatically. Using sqlConn.Insert instead of manually writing out the insert query. --- Samples/Dapper/Program.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Samples/Dapper/Program.cs b/Samples/Dapper/Program.cs index b95d01c..7ababa7 100644 --- a/Samples/Dapper/Program.cs +++ b/Samples/Dapper/Program.cs @@ -76,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); } });