diff --git a/AmalgamationTool/DynamORM.Amalgamation.cs b/AmalgamationTool/DynamORM.Amalgamation.cs
index a1d15ad..e510035 100644
--- a/AmalgamationTool/DynamORM.Amalgamation.cs
+++ b/AmalgamationTool/DynamORM.Amalgamation.cs
@@ -685,6 +685,7 @@ namespace DynamORM
/// Initializes a new instance of the class.
public DynamicColumn()
{
+ ParameterDirection = ParameterDirection.Input;
}
/// Initializes a new instance of the class.
@@ -726,6 +727,9 @@ namespace DynamORM
/// Gets or sets order direction.
public SortOrder Order { get; set; }
+ /// Gets or sets parameter direction when used in procedure invocation.
+ public ParameterDirection ParameterDirection { get; set; }
+
/// Gets or sets value for parameters.
public object Value { get; set; }
@@ -5371,6 +5375,37 @@ namespace DynamORM
cmd.AddParameters(_db, (DynamicExpando)arg);
else if (arg is ExpandoObject)
cmd.AddParameters(_db, (ExpandoObject)arg);
+ else if (arg is DynamicColumn)
+ {
+ var dcv = (DynamicColumn)arg;
+
+ string paramName = dcv.Alias ?? dcv.ColumnName ??
+ (dcv.Schema.HasValue ? dcv.Schema.Value.Name : null) ??
+ (info.ArgumentNames.Count > i ? info.ArgumentNames[i] : i.ToString());
+
+ bool isOut = dcv.ParameterDirection == ParameterDirection.Output ||
+ dcv.ParameterDirection == ParameterDirection.ReturnValue;
+
+ if (isOut || dcv.ParameterDirection == ParameterDirection.InputOutput)
+ {
+ if (retParams == null)
+ retParams = new Dictionary();
+ retParams.Add(paramName, cmd.Parameters.Count);
+ }
+
+ if (dcv.Schema != null)
+ {
+ var ds = dcv.Schema.Value;
+ cmd.AddParameter(
+ _db.GetParameterName(paramName), dcv.ParameterDirection,
+ ds.Type, ds.Size, ds.Precision, ds.Scale,
+ isOut ? DBNull.Value : arg);
+ }
+ else
+ cmd.AddParameter(
+ _db.GetParameterName(paramName), dcv.ParameterDirection,
+ arg == null ? DbType.String : arg.GetType().ToDbType(), 0, isOut ? DBNull.Value : arg);
+ }
else
{
if (info.ArgumentNames.Count > i && !string.IsNullOrEmpty(info.ArgumentNames[i]))
@@ -5473,7 +5508,7 @@ namespace DynamORM
using (IDataReader rdr = cmd.ExecuteReader())
if (rdr.Read())
- mainResult = (rdr.ToDynamic() as object).Map(types[0]);
+ mainResult = (rdr.RowToDynamic() as object).Map(types[0]);
else
mainResult = null;
}
diff --git a/DynamORM.sln b/DynamORM.sln
index 6b45d03..8936f33 100644
--- a/DynamORM.sln
+++ b/DynamORM.sln
@@ -3,13 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamORM", "DynamORM\DynamORM.csproj", "{63963ED7-9C78-4672-A4D4-339B6E825503}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynamORM", "DynamORM\DynamORM.csproj", "{63963ED7-9C78-4672-A4D4-339B6E825503}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamORM.Tests", "DynamORM.Tests\DynamORM.Tests.csproj", "{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AmalgamationTool", "AmalgamationTool\AmalgamationTool.csproj", "{A64D2052-D0CD-488E-BF05-E5952615D926}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tester", "Tester\Tester.csproj", "{F747AA57-BEA7-4FB8-B371-546296789AEF}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tester", "Tester\Tester.csproj", "{F747AA57-BEA7-4FB8-B371-546296789AEF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -53,7 +53,8 @@ Global
{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.Build.0 = Release|x86
- {F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|Any CPU.ActiveCfg = Debug|x86
+ {F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{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|x86.ActiveCfg = Debug|x86
diff --git a/DynamORM/DynamicColumn.cs b/DynamORM/DynamicColumn.cs
index b99e6a8..960646a 100644
--- a/DynamORM/DynamicColumn.cs
+++ b/DynamORM/DynamicColumn.cs
@@ -28,6 +28,7 @@
using System;
using System.Collections.Generic;
+using System.Data;
using System.Text;
namespace DynamORM
@@ -88,6 +89,7 @@ namespace DynamORM
/// Initializes a new instance of the class.
public DynamicColumn()
{
+ ParameterDirection = ParameterDirection.Input;
}
/// Initializes a new instance of the class.
@@ -129,6 +131,9 @@ namespace DynamORM
/// Gets or sets order direction.
public SortOrder Order { get; set; }
+ /// Gets or sets parameter direction when used in procedure invocation.
+ public ParameterDirection ParameterDirection { get; set; }
+
/// Gets or sets value for parameters.
public object Value { get; set; }
diff --git a/DynamORM/DynamicExtensions.cs b/DynamORM/DynamicExtensions.cs
index edd9bb5..5a41aa7 100644
--- a/DynamORM/DynamicExtensions.cs
+++ b/DynamORM/DynamicExtensions.cs
@@ -1014,7 +1014,7 @@ namespace DynamORM
public static List ToList(this IDataReader r)
{
List result = new List();
-
+
while (r.Read())
result.Add(r.RowToDynamic());
diff --git a/DynamORM/DynamicProcedureInvoker.cs b/DynamORM/DynamicProcedureInvoker.cs
index 6cf6f6e..41a7fc7 100644
--- a/DynamORM/DynamicProcedureInvoker.cs
+++ b/DynamORM/DynamicProcedureInvoker.cs
@@ -115,6 +115,35 @@ namespace DynamORM
cmd.AddParameters(_db, (DynamicExpando)arg);
else if (arg is ExpandoObject)
cmd.AddParameters(_db, (ExpandoObject)arg);
+ else if (arg is DynamicColumn)
+ {
+ var dcv = (DynamicColumn)arg;
+
+ string paramName = dcv.Alias ?? dcv.ColumnName ??
+ (dcv.Schema.HasValue ? dcv.Schema.Value.Name : null) ??
+ (info.ArgumentNames.Count > i ? info.ArgumentNames[i] : i.ToString());
+
+ bool isOut = dcv.ParameterDirection == ParameterDirection.Output ||
+ dcv.ParameterDirection == ParameterDirection.ReturnValue;
+
+ if (isOut || dcv.ParameterDirection == ParameterDirection.InputOutput)
+ {
+ if (retParams == null)
+ retParams = new Dictionary();
+ retParams.Add(paramName, cmd.Parameters.Count);
+ }
+
+ if (dcv.Schema != null) {
+ var ds = dcv.Schema.Value;
+ cmd.AddParameter(
+ _db.GetParameterName(paramName), dcv.ParameterDirection,
+ ds.Type, ds.Size, ds.Precision, ds.Scale,
+ isOut ? DBNull.Value : arg);
+ } else
+ cmd.AddParameter(
+ _db.GetParameterName(paramName), dcv.ParameterDirection,
+ arg == null ? DbType.String : arg.GetType().ToDbType(), 0, isOut ? DBNull.Value : arg);
+ }
else
{
if (info.ArgumentNames.Count > i && !string.IsNullOrEmpty(info.ArgumentNames[i]))
@@ -217,7 +246,7 @@ namespace DynamORM
using (IDataReader rdr = cmd.ExecuteReader())
if (rdr.Read())
- mainResult = (rdr.ToDynamic() as object).Map(types[0]);
+ mainResult = (rdr.RowToDynamic() as object).Map(types[0]);
else
mainResult = null;
}
diff --git a/Tester/Program.cs b/Tester/Program.cs
index 6af862e..c1fe5cf 100644
--- a/Tester/Program.cs
+++ b/Tester/Program.cs
@@ -5,13 +5,14 @@ namespace Tester
{
internal class Program
{
- private static DynamORM.DynamicDatabase GetORM()
+ private static DynamicDatabase GetORM()
{
- return new DynamORM.DynamicDatabase(System.Data.SqlClient.SqlClientFactory.Instance,
+ return new DynamicDatabase(System.Data.SqlClient.SqlClientFactory.Instance,
//"packet size=4096;User Id=sa;Password=Sa123;data source=192.168.1.9,1434;initial catalog=MAH_Melle-GAGARIN;",
- "packet size=4096;User Id=sa;Password=sa123;data source=192.168.1.9,1433;initial catalog=MOM_NEXT_Florentyna_WMS_PROD;",
- DynamORM.DynamicDatabaseOptions.SingleConnection | DynamORM.DynamicDatabaseOptions.SingleTransaction | DynamORM.DynamicDatabaseOptions.SupportStoredProcedures |
- DynamORM.DynamicDatabaseOptions.SupportSchema | DynamORM.DynamicDatabaseOptions.SupportTop);
+ //"packet size=4096;User Id=sa;Password=sa123;data source=192.168.1.9,1433;initial catalog=MOM_NEXT_Florentyna_WMS_PROD;",
+ "packet size=4096;User Id=sa;Password=sa123;data source=192.168.0.6;initial catalog=DynamORM;",
+ DynamicDatabaseOptions.SingleConnection | DynamicDatabaseOptions.SingleTransaction | DynamicDatabaseOptions.SupportSchema |
+ DynamicDatabaseOptions.SupportStoredProcedures | DynamicDatabaseOptions.SupportTop | DynamicDatabaseOptions.DumpCommands);
////return new DynamORM.DynamicDatabase(System.Data.SQLite.SQLiteFactory.Instance,
//// "Data Source=test.db3;",
@@ -21,30 +22,43 @@ namespace Tester
private static void Main(string[] args)
{
- 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;");
+ var c = new System.Data.SqlClient.SqlConnection("packet size=4096;User Id=sa;Password=sa123;data source=192.168.0.6;initial catalog=DynamORM;");
- DynamicDatabase db = new DynamicDatabase(c,
- DynamicDatabaseOptions.SingleConnection | DynamicDatabaseOptions.SingleTransaction | DynamicDatabaseOptions.SupportSchema |
- DynamicDatabaseOptions.SupportStoredProcedures | DynamicDatabaseOptions.SupportTop | DynamicDatabaseOptions.DumpCommands);
-
- try
+ using (var db = GetORM())
{
+ try
+ {
+ db.Execute("DROP TABLE Experiments ");
+ }
+ catch { }
+
+ db.Execute("CREATE TABLE Experiments (t1 nvarchar(50) NOT NULL DEFAULT N'', t2 varchar(50) NOT NULL DEFAULT '');");
+
+ //var q = db.From(x => x.Experiments.As(x.e1));
+ //q
+ // .Where(x => x.t2 = "Dupa")
+ // .Where(x => x.Exists(
+ // q.SubQuery()
+ // .From(y => y.Experiments.As(x.e2))
+ // .Where(y => y.e2.t1 == y.e1.t1)))
+ // .Execute().ToList();
+
db.Execute("DROP TABLE Experiments ");
+
+ var resL = db.Procedures.GetProductDesc>();
+ var res = db.Procedures.GetProductDesc_withparameters(PID: 707);
+ res = db.Procedures.GetProductDesc_withDefaultparameters();
+
+ int id = -1;
+ var resD = db.Procedures.ins_NewEmp_with_outputparamaters(Ename: "Test2", out_EId: id);
}
- catch { }
+ }
- db.Execute("CREATE TABLE Experiments (t1 nvarchar(50) NOT NULL DEFAULT N'', t2 varchar(50) NOT NULL DEFAULT '');");
-
- var q = db.From(x => x.Experiments.As(x.e1));
- q
- .Where(x => x.t2 = "Dupą")
- .Where(x => x.Exists(
- q.SubQuery()
- .From(y => y.Experiments.As(x.e2))
- .Where(y => y.e2.t1 == y.e1.t1)))
- .Execute().ToList();
-
- db.Execute("DROP TABLE Experiments ");
+ private class GetProductDesc_Result
+ {
+ public virtual int ProductID { get; set; }
+ public virtual string ProductName { get; set; }
+ public virtual string ProductDescription { get; set; }
}
}
}
\ No newline at end of file
diff --git a/Tester/Properties/AssemblyInfo.cs b/Tester/Properties/AssemblyInfo.cs
deleted file mode 100644
index 94d8667..0000000
--- a/Tester/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Tester")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Microsoft")]
-[assembly: AssemblyProduct("Tester")]
-[assembly: AssemblyCopyright("Copyright © Microsoft 2014")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("dbff9475-06f5-400e-bc17-57c14d9d9cb9")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Tester/Tester.csproj b/Tester/Tester.csproj
index 99321de..c63bb2a 100644
--- a/Tester/Tester.csproj
+++ b/Tester/Tester.csproj
@@ -1,77 +1,32 @@
-
-
-
- Debug
- x86
- 8.0.30703
- 2.0
- {F747AA57-BEA7-4FB8-B371-546296789AEF}
- Exe
- Properties
- Tester
- Tester
- v4.8
-
-
- 512
-
-
- x86
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- true
- false
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
- true
- false
-
-
-
-
-
- C:\Program Files\System.Data.SQLite\2010\bin\System.Data.SQLite.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {63963ED7-9C78-4672-A4D4-339B6E825503}
- DynamORM
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+ Exe
+ netcoreapp3.1
+ Copyright © RUSSEK Software 2012-2022
+ RUSSEK Software
+ Grzegorz Russek
+ 1.2.1
+ https://svn.dr4cul4.pl/svn/DynamORM/
+ https://dr4cul4.pl
+ DynamORM
+ MIT
+ Exe
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+