Skip to content

Commit 6a68b00

Browse files
committed
Switch nuget package from [DataBooster for SQL Server ] to [DataBooster for SQL Server + Oracle (use ODP.NET Managed Driver)]
1 parent 2255792 commit 6a68b00

File tree

7 files changed

+139
-11
lines changed

7 files changed

+139
-11
lines changed

T4SQLTemplateLibrary/SqlBuilder/DataAccess/ConfigHelper.sample.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public static partial class ConfigHelper
88
#region Setting key names defined in your config file, can be overridden in partial OnInitializing()
99
private static string _ConnectionSettingKey = "T4SQL.SqlBuilder.MainConnection";
1010
private static string _PackageSettingKey = "T4SQL.SqlBuilder.MainPackage";
11+
private static string _AuxConnectionSettingKey = "T4SQL.SqlBuilder.AuxConnection";
1112
#endregion
1213

1314
#region Properties
@@ -28,6 +29,18 @@ public static string DatabasePackage
2829
{
2930
get { return _DatabasePackage; }
3031
}
32+
33+
private static DbProviderFactory _AuxDbProviderFactory;
34+
public static DbProviderFactory AuxDbProviderFactory
35+
{
36+
get { return _AuxDbProviderFactory; }
37+
}
38+
39+
private static string _AuxConnectionString;
40+
public static string AuxConnectionString
41+
{
42+
get { return _AuxConnectionString; }
43+
}
3144
#endregion
3245

3346
static ConfigHelper()
@@ -42,6 +55,10 @@ static ConfigHelper()
4255
_DatabasePackage = ConfigurationManager.AppSettings[_PackageSettingKey];
4356
if (_DatabasePackage == null)
4457
_DatabasePackage = string.Empty;
58+
59+
connSetting = ConfigurationManager.ConnectionStrings[_AuxConnectionSettingKey];
60+
_AuxDbProviderFactory = DbProviderFactories.GetFactory(connSetting.ProviderName);
61+
_AuxConnectionString = connSetting.ConnectionString;
4562
#endregion
4663

4764
OnInitialized();

T4SQLTemplateLibrary/SqlBuilder/DataAccess/DbPackage.sample.cs

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
using System.Data.Common;
44
using System.Data.SqlClient;
55
using System.Collections.Generic;
6+
using Oracle.ManagedDataAccess.Client;
67
using DbParallel.DataAccess;
8+
using DbParallel.DataAccess.Booster.Oracle;
79
using DbParallel.DataAccess.Booster.SqlServer;
810

911
namespace T4SQL.SqlBuilder.DataAccess
@@ -155,9 +157,10 @@ public static void LogSampleError(this DbAccess dbAccess, string strReference, s
155157
#endregion
156158

157159
#region A sample of using SqlLauncher class
160+
158161
public static SqlLauncher CreateSampleSqlLauncher()
159162
{
160-
return new SqlLauncher(ConfigHelper.ConnectionString, "schema.DestBigTable",
163+
return new SqlLauncher(ConfigHelper.AuxConnectionString, "schema.DestBigTable",
161164
/* (Optional)
162165
* If the data source and the destination table have the same number of columns,
163166
* and the ordinal position of each source column within the data source matches the ordinal position
@@ -179,6 +182,70 @@ public static void AddSampleSqlRow(this SqlLauncher launcher, int col0, string c
179182
{
180183
launcher.Post(col0, col1, col2);
181184
}
185+
186+
#endregion
187+
188+
#region A sample of using OracleLauncher class
189+
190+
public static OracleLauncher CreateSampleOraLauncher(int grpId)
191+
{
192+
return new OracleLauncher(ConfigHelper.ConnectionString, GetProcedure("WRITE_BULK_DATA"),
193+
parameters =>
194+
{
195+
parameters.Add("inGroup_ID", grpId); // Ordinary parameter
196+
197+
// All Array Bind Types must be explicitly specified and must match PL/SQL table row types defined in database side
198+
parameters.AddAssociativeArray("inItem_IDs", OracleDbType.Int32);
199+
parameters.AddAssociativeArray("inItem_Values", OracleDbType.BinaryDouble);
200+
});
201+
}
202+
203+
public static void AddSampleOraRow(this OracleLauncher launcher, int itemId, double itemValue)
204+
{
205+
launcher.Post(itemId, itemValue);
206+
}
207+
208+
// The database side package:
209+
210+
// CREATE OR REPLACE PACKAGE SCHEMA.PACKAGE IS
211+
// TYPE NUMBER_ARRAY IS TABLE OF NUMBER INDEX BY PLS_INTEGER;
212+
// TYPE DOUBLE_ARRAY IS TABLE OF BINARY_DOUBLE INDEX BY PLS_INTEGER;
213+
// -- ...
214+
// PROCEDURE WRITE_BULK_DATA
215+
// (
216+
// inGroup_ID NUMBER,
217+
// inItem_IDs NUMBER_ARRAY,
218+
// inItem_Values DOUBLE_ARRAY
219+
// );
220+
// -- ...
221+
// END PACKAGE;
222+
// /
223+
// CREATE OR REPLACE PACKAGE BODY SCHEMA.PACKAGE IS
224+
// -- ...
225+
// PROCEDURE WRITE_BULK_DATA
226+
// (
227+
// inGroup_ID NUMBER,
228+
// inItem_IDs NUMBER_ARRAY,
229+
// inItem_Values DOUBLE_ARRAY
230+
// ) AS
231+
// BEGIN
232+
// FORALL i IN inItem_IDs.FIRST .. inItem_IDs.LAST
233+
// INSERT /*+ APPEND_VALUES */ INTO SCHEMA.TEST_WRITE_DATA
234+
// (
235+
// GROUP_ID,
236+
// ITEM_ID,
237+
// ITEM_VALUE
238+
// )
239+
// VALUES
240+
// (
241+
// inGroup_ID,
242+
// inItem_IDs(i),
243+
// inItem_Values(i)
244+
// );
245+
// COMMIT;
246+
// END WRITE_BULK_DATA;
247+
// -- ...
248+
// END PACKAGE;
182249
#endregion
183250
#endif
184251
#endregion

T4SQLTemplateLibrary/SqlBuilder/DataAccess/MyBizMain.sample.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Threading.Tasks;
77
using DbParallel.DataAccess;
8+
using DbParallel.DataAccess.Booster.Oracle;
89
using DbParallel.DataAccess.Booster.SqlServer;
910
using T4SQL.SqlBuilder.DataAccess;
1011

@@ -48,6 +49,20 @@ public void MyTestSqlLauncher()
4849
});
4950
}
5051
}
52+
53+
public void MyTestOracleLauncher()
54+
{
55+
using (OracleLauncher launcher = DbPackage.CreateSampleOraLauncher(1001))
56+
{
57+
Parallel.For(0, 100, i => // Just simulating multiple(100) producers
58+
{
59+
for (int j = 0; j < 200000; j++)
60+
{
61+
launcher.AddSampleOraRow(i * 200000 + j, (double)j * 0.618);
62+
}
63+
});
64+
}
65+
}
5166
}
5267
}
5368
#endif

T4SQLTemplateLibrary/SqlBuilder/SqlBuilder.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@
3939
</PropertyGroup>
4040
<ItemGroup>
4141
<Reference Include="DbParallel.DataAccess, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
42-
<SpecificVersion>False</SpecificVersion>
43-
<HintPath>..\packages\DataBooster.SqlServer.1.1.0.0\lib\net40-Client\DbParallel.DataAccess.dll</HintPath>
42+
<HintPath>..\packages\DataBooster.Oracle.Managed.1.1.0.0\lib\net40-Client\DbParallel.DataAccess.dll</HintPath>
43+
</Reference>
44+
<Reference Include="Oracle.ManagedDataAccess">
45+
<HintPath>..\packages\odp.net.managed.121.1.1\lib\net40\Oracle.ManagedDataAccess.dll</HintPath>
4446
</Reference>
4547
<Reference Include="System" />
4648
<Reference Include="System.configuration" />
Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3-
<connectionStrings>
4-
<add name="T4SQL.SqlBuilder.MainConnection" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=SAMPLEDB;Integrated Security=True" />
5-
</connectionStrings>
6-
<appSettings>
7-
<add key="T4SQL.SqlBuilder.MainPackage" value="SCHEMA.PACKAGE_" />
8-
</appSettings>
9-
</configuration>
3+
<configSections>
4+
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess" />
5+
</configSections>
6+
<connectionStrings>
7+
<add name="T4SQL.SqlBuilder.MainConnection" providerName="Oracle.ManagedDataAccess.Client" connectionString="Data Source=SAMPLEDB;User Id=/" />
8+
<add name="T4SQL.SqlBuilder.AuxConnection" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=SAMPLEDB;Integrated Security=True" />
9+
</connectionStrings>
10+
<appSettings>
11+
<add key="T4SQL.SqlBuilder.MainPackage" value="SCHEMA.PACKAGE." />
12+
</appSettings>
13+
<system.data>
14+
<DbProviderFactories>
15+
<!-- Remove in case this is already defined in machine.config -->
16+
<remove invariant="Oracle.ManagedDataAccess.Client" />
17+
<add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess" />
18+
</DbProviderFactories>
19+
</system.data>
20+
<oracle.manageddataaccess.client>
21+
<version number="*">
22+
<settings>
23+
<!-- Set this path if you are using TNS aliases as connection strings -->
24+
<!-- Instead you can use "SERVER_NAME:PORT/SERVICE_NAME" as your data source -->
25+
<setting name="TNS_ADMIN" value="C:\oracle\product\11.2.0\client_1\network\admin" />
26+
</settings>
27+
</version>
28+
</oracle.manageddataaccess.client>
29+
</configuration>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="DataBooster.SqlServer" version="1.1.0.0" targetFramework="net40-Client" />
3+
<package id="DataBooster.Oracle.Managed" version="1.1.0.0" targetFramework="net40-Client" />
4+
<package id="odp.net.managed" version="121.1.1" targetFramework="net40-Client" />
45
</packages>

T4SQLTemplateLibrary/T4SQLTemplateLibrary.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nupkg", "nupkg", "{EFA2A4E4
6868
T4SQL.Base\NuGet\nupkg\Download NuGet Command-Line.htm = T4SQL.Base\NuGet\nupkg\Download NuGet Command-Line.htm
6969
EndProjectSection
7070
EndProject
71+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "packages", "packages", "{2A1C5C78-2B79-493D-9467-365A50744259}"
72+
ProjectSection(SolutionItems) = preProject
73+
packages\repositories.config = packages\repositories.config
74+
EndProjectSection
75+
EndProject
7176
Global
7277
GlobalSection(TeamFoundationVersionControl) = preSolution
7378
SccNumberOfProjects = 9
@@ -165,5 +170,6 @@ Global
165170
{304335BC-9CD9-4D9C-B87B-CE9FBBACAFFA} = {FF43D7CC-1C03-4685-936F-69853A5315F4}
166171
{15675A2B-48D5-484F-B908-82A8E744A6C0} = {AD2C96A3-8A0E-4D50-A703-CDDC43D11284}
167172
{EFA2A4E4-F055-4068-A437-3E9310E27D73} = {304335BC-9CD9-4D9C-B87B-CE9FBBACAFFA}
173+
{2A1C5C78-2B79-493D-9467-365A50744259} = {F939D93A-F5D6-44B3-80BD-139FA7655866}
168174
EndGlobalSection
169175
EndGlobal

0 commit comments

Comments
 (0)