This commit is contained in:
49
DynamORM.sln
49
DynamORM.sln
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 2010
|
# Visual Studio 15
|
||||||
|
VisualStudioVersion = 15.0.28307.136
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamORM", "DynamORM\DynamORM.csproj", "{63963ED7-9C78-4672-A4D4-339B6E825503}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamORM", "DynamORM\DynamORM.csproj", "{63963ED7-9C78-4672-A4D4-339B6E825503}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamORM.Tests", "DynamORM.Tests\DynamORM.Tests.csproj", "{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamORM.Tests", "DynamORM.Tests\DynamORM.Tests.csproj", "{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}"
|
||||||
@@ -9,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AmalgamationTool", "Amalgam
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tester", "Tester\Tester.csproj", "{F747AA57-BEA7-4FB8-B371-546296789AEF}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tester", "Tester\Tester.csproj", "{F747AA57-BEA7-4FB8-B371-546296789AEF}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynamORM.Core", "DynamORM\DynamORM.Core.csproj", "{90D18618-B92E-41E5-9099-A7352E4E5C18}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -29,6 +33,16 @@ Global
|
|||||||
{63963ED7-9C78-4672-A4D4-339B6E825503}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
{63963ED7-9C78-4672-A4D4-339B6E825503}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
{63963ED7-9C78-4672-A4D4-339B6E825503}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
{63963ED7-9C78-4672-A4D4-339B6E825503}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
{63963ED7-9C78-4672-A4D4-339B6E825503}.Release|x86.ActiveCfg = Release|Any CPU
|
{63963ED7-9C78-4672-A4D4-339B6E825503}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|Any CPU.ActiveCfg = Debug|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|Any CPU.Build.0 = Debug|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|Any CPU.Build.0 = Debug|x86
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||||
@@ -41,16 +55,6 @@ Global
|
|||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|Mixed Platforms.Build.0 = Release|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|x86.ActiveCfg = Release|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|x86.ActiveCfg = Release|x86
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|x86.Build.0 = Release|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|x86.Build.0 = Release|x86
|
||||||
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
|
||||||
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
|
||||||
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Debug|x86.ActiveCfg = Debug|Any CPU
|
|
||||||
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
|
||||||
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
|
||||||
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Release|x86.ActiveCfg = Release|Any CPU
|
|
||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|Any CPU.ActiveCfg = Debug|x86
|
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||||
@@ -61,11 +65,26 @@ Global
|
|||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Release|Mixed Platforms.Build.0 = Release|x86
|
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Release|x86.ActiveCfg = Release|x86
|
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Release|x86.ActiveCfg = Release|x86
|
||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Release|x86.Build.0 = Release|x86
|
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Release|x86.Build.0 = Release|x86
|
||||||
EndGlobalSection
|
{90D18618-B92E-41E5-9099-A7352E4E5C18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
GlobalSection(MonoDevelopProperties) = preSolution
|
{90D18618-B92E-41E5-9099-A7352E4E5C18}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
StartupItem = Tester\Tester.csproj
|
{90D18618-B92E-41E5-9099-A7352E4E5C18}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{90D18618-B92E-41E5-9099-A7352E4E5C18}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{90D18618-B92E-41E5-9099-A7352E4E5C18}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{90D18618-B92E-41E5-9099-A7352E4E5C18}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{90D18618-B92E-41E5-9099-A7352E4E5C18}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{90D18618-B92E-41E5-9099-A7352E4E5C18}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{90D18618-B92E-41E5-9099-A7352E4E5C18}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{90D18618-B92E-41E5-9099-A7352E4E5C18}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{90D18618-B92E-41E5-9099-A7352E4E5C18}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{90D18618-B92E-41E5-9099-A7352E4E5C18}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {B94FC164-4357-4FDA-A844-5202FA8C5E4B}
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(MonoDevelopProperties) = preSolution
|
||||||
|
StartupItem = Tester\Tester.csproj
|
||||||
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
17
DynamORM/DynamORM.Core.csproj
Normal file
17
DynamORM/DynamORM.Core.csproj
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
|
<Description>Dynamic Object-Relational Mapping library.</Description>
|
||||||
|
<Copyright>Copyright © RUSSEK Software 2012-2019</Copyright>
|
||||||
|
<Company>RUSSEK Software</Company>
|
||||||
|
<Authors>Grzegorz Russek</Authors>
|
||||||
|
<FileVersion>1.1.0.1</FileVersion>
|
||||||
|
<AssemblyVersion>1.1.0.1</AssemblyVersion>
|
||||||
|
<RepositoryUrl>https://dr4cul4.pl/svn/DynamORM/</RepositoryUrl>
|
||||||
|
<PackageProjectUrl>https://dr4cul4.pl</PackageProjectUrl>
|
||||||
|
<Product>DynamORM</Product>
|
||||||
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -33,6 +33,7 @@ using System.Data;
|
|||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using DynamORM.Builders;
|
using DynamORM.Builders;
|
||||||
using DynamORM.Builders.Extensions;
|
using DynamORM.Builders.Extensions;
|
||||||
@@ -166,19 +167,61 @@ namespace DynamORM
|
|||||||
InitCommon(connectionString, options);
|
InitCommon(connectionString, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DbProviderFactory FindDbProviderFactoryFromConnection(Type t)
|
||||||
|
{
|
||||||
|
foreach (var type in t.Assembly.GetTypes().Where(x => x.IsSubclassOf(typeof(DbProviderFactory))))
|
||||||
|
{
|
||||||
|
DbProviderFactory provider = null;
|
||||||
|
bool dispose = false;
|
||||||
|
|
||||||
|
var pi = type.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.GetProperty);
|
||||||
|
if (pi != null)
|
||||||
|
provider = (DbProviderFactory)pi.GetValue(null, null);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var fi = type.GetField("Instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.GetField);
|
||||||
|
if (fi != null)
|
||||||
|
provider = (DbProviderFactory)fi.GetValue(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (provider == null)
|
||||||
|
{
|
||||||
|
var ci = type.GetConstructor(Type.EmptyTypes);
|
||||||
|
if (ci != null)
|
||||||
|
{
|
||||||
|
provider = ci.Invoke(null) as DbProviderFactory;
|
||||||
|
dispose = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (provider != null)
|
||||||
|
{
|
||||||
|
using (var c = provider.CreateConnection())
|
||||||
|
{
|
||||||
|
if (c.GetType() == t)
|
||||||
|
return provider;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (provider != null && dispose && provider is IDisposable)
|
||||||
|
((IDisposable)provider).Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="DynamicDatabase" /> class.</summary>
|
/// <summary>Initializes a new instance of the <see cref="DynamicDatabase" /> class.</summary>
|
||||||
/// <param name="connection">Active database connection.</param>
|
/// <param name="connection">Active database connection.</param>
|
||||||
/// <param name="options">Connection options. <see cref="DynamicDatabaseOptions.SingleConnection"/> required.</param>
|
/// <param name="options">Connection options. <see cref="DynamicDatabaseOptions.SingleConnection"/> required.</param>
|
||||||
public DynamicDatabase(IDbConnection connection, DynamicDatabaseOptions options)
|
public DynamicDatabase(IDbConnection connection, DynamicDatabaseOptions options)
|
||||||
{
|
{
|
||||||
// Try to find correct provider if possible
|
// Try to find correct provider if possible
|
||||||
Type t = connection.GetType();
|
_provider = FindDbProviderFactoryFromConnection(connection.GetType());
|
||||||
if (t == typeof(System.Data.SqlClient.SqlConnection))
|
|
||||||
_provider = System.Data.SqlClient.SqlClientFactory.Instance;
|
|
||||||
else if (t == typeof(System.Data.Odbc.OdbcConnection))
|
|
||||||
_provider = System.Data.Odbc.OdbcFactory.Instance;
|
|
||||||
else if (t == typeof(System.Data.OleDb.OleDbConnection))
|
|
||||||
_provider = System.Data.OleDb.OleDbFactory.Instance;
|
|
||||||
|
|
||||||
IsDisposed = false;
|
IsDisposed = false;
|
||||||
InitCommon(connection.ConnectionString, options);
|
InitCommon(connection.ConnectionString, options);
|
||||||
@@ -1441,7 +1484,7 @@ namespace DynamORM
|
|||||||
Type type = (Type)schema.DATATYPE;
|
Type type = (Type)schema.DATATYPE;
|
||||||
|
|
||||||
// Small hack for SQL Server Provider
|
// Small hack for SQL Server Provider
|
||||||
if (type == typeof(string) && Provider != null && Provider.GetType() == typeof(System.Data.SqlClient.SqlClientFactory))
|
if (type == typeof(string) && Provider != null && Provider.GetType().Name == "SqlClientFactory")
|
||||||
{
|
{
|
||||||
var map = schema as IDictionary<string, object>;
|
var map = schema as IDictionary<string, object>;
|
||||||
string typeName = (map.TryGetValue("DATATYPENAME") ?? string.Empty).ToString();
|
string typeName = (map.TryGetValue("DATATYPENAME") ?? string.Empty).ToString();
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("RUSSEK Software")]
|
[assembly: AssemblyCompany("RUSSEK Software")]
|
||||||
[assembly: AssemblyProduct("DynamORM")]
|
[assembly: AssemblyProduct("DynamORM")]
|
||||||
[assembly: AssemblyCopyright("Copyright © RUSSEK Software 2012")]
|
[assembly: AssemblyCopyright("Copyright © RUSSEK Software 2012-2019")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ namespace Tester
|
|||||||
|
|
||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
DynamicDatabase db = new DynamicDatabase(System.Data.SqlClient.SqlClientFactory.Instance, "packet size=4096;User Id=sa;Password=Sa123;data source=127.0.0.1,1434;initial catalog=MAH_Levant;",
|
var c = new System.Data.SqlClient.SqlConnection("packet size=4096;User Id=sa;Password=Sa123;data source=127.0.0.1,1434;initial catalog=MAH_Levant;");
|
||||||
|
|
||||||
|
DynamicDatabase db = new DynamicDatabase(c,
|
||||||
DynamicDatabaseOptions.SingleConnection | DynamicDatabaseOptions.SingleTransaction | DynamicDatabaseOptions.SupportSchema |
|
DynamicDatabaseOptions.SingleConnection | DynamicDatabaseOptions.SingleTransaction | DynamicDatabaseOptions.SupportSchema |
|
||||||
DynamicDatabaseOptions.SupportStoredProcedures | DynamicDatabaseOptions.SupportTop | DynamicDatabaseOptions.DumpCommands);
|
DynamicDatabaseOptions.SupportStoredProcedures | DynamicDatabaseOptions.SupportTop | DynamicDatabaseOptions.DumpCommands);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user