diff --git a/.gitignore b/.gitignore index 4f0946d..ecbc6f9 100644 --- a/.gitignore +++ b/.gitignore @@ -62,4 +62,5 @@ packages/ *.dbmdl #Test files -*.testsettings \ No newline at end of file +*.testsettings +/.vs diff --git a/README.md b/README.md index 2f8d25b..9c4206a 100644 --- a/README.md +++ b/README.md @@ -480,7 +480,7 @@ Note that connections will inherit from your machine.config & root web.config fi ## Requirements -* .NET Framework 4.0+ +* .NET Standard 2.0 * SQL Server 2008+ if you want to use table-valued parameters, otherwise SQL Server 2000+ ## Contact diff --git a/src/unQuery.PerformanceTests/App.config b/src/unQuery.PerformanceTests/App.config index 07a2439..20ad4d4 100644 --- a/src/unQuery.PerformanceTests/App.config +++ b/src/unQuery.PerformanceTests/App.config @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/src/unQuery.PerformanceTests/Properties/AssemblyInfo.cs b/src/unQuery.PerformanceTests/Properties/AssemblyInfo.cs index 1f2d19e..b34c20f 100644 --- a/src/unQuery.PerformanceTests/Properties/AssemblyInfo.cs +++ b/src/unQuery.PerformanceTests/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/src/unQuery.PerformanceTests/TestFixture.cs b/src/unQuery.PerformanceTests/TestFixture.cs index 23dda68..18b4e3e 100644 --- a/src/unQuery.PerformanceTests/TestFixture.cs +++ b/src/unQuery.PerformanceTests/TestFixture.cs @@ -18,7 +18,7 @@ public abstract class TestFixture private double testPercentile = 0.90d; private string connectionString = ConfigurationManager.ConnectionStrings["TestDB"].ConnectionString; - [TestFixtureSetUp] + [OneTimeSetUp] public void Init() { // Increase process priority since this is time sensitive code diff --git a/src/unQuery.PerformanceTests/packages.config b/src/unQuery.PerformanceTests/packages.config index 5a3253f..5fb03be 100644 --- a/src/unQuery.PerformanceTests/packages.config +++ b/src/unQuery.PerformanceTests/packages.config @@ -1,4 +1,9 @@  - + + + + + + \ No newline at end of file diff --git a/src/unQuery.PerformanceTests/unQuery.PerformanceTests.csproj b/src/unQuery.PerformanceTests/unQuery.PerformanceTests.csproj index 5e17daf..58e3740 100644 --- a/src/unQuery.PerformanceTests/unQuery.PerformanceTests.csproj +++ b/src/unQuery.PerformanceTests/unQuery.PerformanceTests.csproj @@ -1,7 +1,9 @@  - + + + true Debug AnyCPU {8658B682-8FE7-44B8-ACD4-1D95F80DB083} @@ -9,10 +11,13 @@ Properties unQuery.PerformanceTests unQuery.PerformanceTests - v4.0 + v4.7.2 512 ..\..\ true + + + AnyCPU @@ -23,6 +28,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU @@ -33,23 +39,45 @@ prompt 4 false + false - - False - ..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll + + ..\..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll + + ..\..\packages\System.Configuration.ConfigurationManager.4.6.0\lib\net461\System.Configuration.ConfigurationManager.dll + + + + + ..\..\packages\System.Data.SqlClient.4.8.6\lib\net461\System.Data.SqlClient.dll + True + + + + + + ..\..\packages\System.Security.AccessControl.4.6.0\lib\net461\System.Security.AccessControl.dll + + + ..\..\packages\System.Security.Permissions.4.6.0\lib\net461\System.Security.Permissions.dll + + + ..\..\packages\System.Security.Principal.Windows.4.6.0\lib\net461\System.Security.Principal.Windows.dll + + + - - + @@ -75,6 +103,12 @@ + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + - \ No newline at end of file + + + + netstandard2.0 + 0.1.9 + Mark S. Rasmussen + https://raw.github.com/improvedk/unQuery/master/license.txt + + + https://github.com/improvedk/unQuery + unQuery is a minimal data access library that makes it as simple as possible to consume and interact with data in SQL Server. + 0.1.9 +- Ported to .NET Standard 2.0. +0.1.8 +- Now handles emply table-valued parameter input +- Result column access is now case insensitive +- Added support for stored procedures +- Added support for QueryOptions +- Batch Executor now clears stored commands after executing +0.1.7 +- Better LINQPad formatting +- Improved exception messages +- Support for mapping rows into lists of simple types +- All exceptions are now serializable +- Minor performance optimization +0.1.6 +- unQueryDB is now Serializable +0.1.5 +- Now supports mapping results into strong types +0.1.4 +- Massive performance improvements in parameter parsing +- Added Batch() functionality +- Now targets .NET 4.0 rather than 4.5 +0.1.3 +- Table valued parameter performance increase +0.1.2 +- Added support for all common SQL Server data types +- Added support for table-valued parameters +- Updated documentation +- Performance improvements +0.1.1 +- Initial release + + + + + + + + + diff --git a/src/unQuery/unQuery.nuspec b/src/unQuery/unQuery.nuspec deleted file mode 100644 index 6469a3d..0000000 --- a/src/unQuery/unQuery.nuspec +++ /dev/null @@ -1,46 +0,0 @@ - - - - unQuery - $version$ - unQuery - Mark S. Rasmussen - Mark S. Rasmussen - https://raw.github.com/improvedk/unQuery/master/license.txt - https://github.com/improvedk/unQuery - false - unQuery is a minimal data access library that makes it as simple as possible to consume and interact with data in SQL Server. - - 0.1.8 - - Now handles emply table-valued parameter input - - Result column access is now case insensitive - - Added support for stored procedures - - Added support for QueryOptions - - Batch Executor now clears stored commands after executing - 0.1.7 - - Better LINQPad formatting - - Improved exception messages - - Support for mapping rows into lists of simple types - - All exceptions are now serializable - - Minor performance optimization - 0.1.6 - - unQueryDB is now Serializable - 0.1.5 - - Now supports mapping results into strong types - 0.1.4 - - Massive performance improvements in parameter parsing - - Added Batch() functionality - - Now targets .NET 4.0 rather than 4.5 - 0.1.3 - - Table valued parameter performance increase - 0.1.2 - - Added support for all common SQL Server data types - - Added support for table-valued parameters - - Updated documentation - - Performance improvements - 0.1.1 - - Initial release - - SQL Micro-ORM DAL DB SQLServer - - \ No newline at end of file diff --git a/src/unQuery/unQueryDB.cs b/src/unQuery/unQueryDB.cs index 0ae96bf..9a8758b 100644 --- a/src/unQuery/unQueryDB.cs +++ b/src/unQuery/unQueryDB.cs @@ -280,7 +280,7 @@ internal void AddParametersToCommand(SqlParameterCollection paramCollection, obj il.Emit(OpCodes.Call, typeof(SqlParameter).GetMethod("set_ParameterName")); // Set the parameter name [] il.Emit(OpCodes.Ldarg_0); // Load the param collection [paramCollection] il.Emit(OpCodes.Ldloc, paramLocIndex); // Load the parameter [paramCollection, param] - il.Emit(OpCodes.Call, typeof(SqlParameterCollection).GetMethod("Add", new[] { typeof(SqlParameter) })); // Add the parameter to the collection [param] + il.Emit(OpCodes.Call, typeof(SqlParameterCollection).GetMethod(nameof(SqlParameterCollection.Add), new[] { typeof(SqlParameter) })); // Add the parameter to the collection [param] il.Emit(OpCodes.Pop); // Get rid of the added parameter, as returned by SqlParameterCollection.Add [] } else @@ -291,8 +291,8 @@ internal void AddParametersToCommand(SqlParameterCollection paramCollection, obj il.Emit(OpCodes.Ldloc_0); // Load the object [paramCollection, typeHandler, paramName, object] il.Emit(OpCodes.Call, prop.GetGetMethod()); // Get the property value [paramCollection, typeHandler, paramName, value] il.Emit(OpCodes.Box, prop.PropertyType); // Box the value [paramCollection, typeHandler, paramName, boxedValue] - il.Emit(OpCodes.Callvirt, typeof(SqlTypeHandler).GetMethod("CreateParamFromValue", BindingFlags.NonPublic | BindingFlags.Instance, null, new[] { typeof(string), typeof(object) }, null)); // Let the type handler create the param [paramCollection, param] - il.Emit(OpCodes.Call, typeof(SqlParameterCollection).GetMethod("Add", new[] { typeof(SqlParameter) })); // Add the parameter to the collection [param] + il.Emit(OpCodes.Callvirt, typeof(SqlTypeHandler).GetMethod(nameof(SqlTypeHandler.CreateParamFromValue), BindingFlags.NonPublic | BindingFlags.Instance, null, new[] { typeof(string), typeof(object) }, null)); // Let the type handler create the param [paramCollection, param] + il.Emit(OpCodes.Call, typeof(SqlParameterCollection).GetMethod(nameof(SqlParameterCollection.Add), new[] { typeof(SqlParameter) })); // Add the parameter to the collection [param] il.Emit(OpCodes.Pop); // Get rid of the param as we don't need it anymore []*/ } } @@ -307,8 +307,7 @@ internal void AddParametersToCommand(SqlParameterCollection paramCollection, obj } // Run the cached parameter adder - if (parameterAdder != null) - parameterAdder(paramCollection, parameters); + parameterAdder?.Invoke(paramCollection, parameters); } /// @@ -388,10 +387,11 @@ private IEnumerable mapReaderRowsToType(SqlDataReader reader, Func type var type = typeof(T); PropertyInfo[] properties = type.GetProperties(); - var schema = reader.GetSchemaTable().AsEnumerable().Select(x => new + var table = reader.GetSchemaTable(); + var schema = table.Select().Select(x => new { - Name = x.Field("ColumnName"), - Ordinal = x.Field("ColumnOrdinal") + Name = (string)x.ItemArray[table.Columns.IndexOf("ColumnName")], + Ordinal = (int)x.ItemArray[table.Columns.IndexOf("ColumnOrdinal")] }); // If there are no properties on the type, it doesn't make sense to use it here diff --git a/unQuery.sln b/unQuery.sln index 1b2a9bd..0269da8 100644 --- a/unQuery.sln +++ b/unQuery.sln @@ -1,10 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30110.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "unQuery", "src\unQuery\unQuery.csproj", "{D527620B-C076-4ADF-B73E-AF00771B2146}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "unQuery.Tests", "src\unQuery.Tests\unQuery.Tests.csproj", "{48FA9377-83EC-455E-BA73-11F54B058ADA}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6BA2AE24-748D-42D2-9FD3-5310EBD5B072}" @@ -16,16 +14,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "unQuery.PerformanceTests", "src\unQuery.PerformanceTests\unQuery.PerformanceTests.csproj", "{8658B682-8FE7-44B8-ACD4-1D95F80DB083}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "unQuery", "src\unQuery\unQuery.csproj", "{39CEE33A-B42F-4ACD-A1F0-5EFA98CD7A4B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D527620B-C076-4ADF-B73E-AF00771B2146}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D527620B-C076-4ADF-B73E-AF00771B2146}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D527620B-C076-4ADF-B73E-AF00771B2146}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D527620B-C076-4ADF-B73E-AF00771B2146}.Release|Any CPU.Build.0 = Release|Any CPU {48FA9377-83EC-455E-BA73-11F54B058ADA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {48FA9377-83EC-455E-BA73-11F54B058ADA}.Debug|Any CPU.Build.0 = Debug|Any CPU {48FA9377-83EC-455E-BA73-11F54B058ADA}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -34,8 +30,15 @@ Global {8658B682-8FE7-44B8-ACD4-1D95F80DB083}.Debug|Any CPU.Build.0 = Debug|Any CPU {8658B682-8FE7-44B8-ACD4-1D95F80DB083}.Release|Any CPU.ActiveCfg = Release|Any CPU {8658B682-8FE7-44B8-ACD4-1D95F80DB083}.Release|Any CPU.Build.0 = Release|Any CPU + {39CEE33A-B42F-4ACD-A1F0-5EFA98CD7A4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {39CEE33A-B42F-4ACD-A1F0-5EFA98CD7A4B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {39CEE33A-B42F-4ACD-A1F0-5EFA98CD7A4B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {39CEE33A-B42F-4ACD-A1F0-5EFA98CD7A4B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {74ECB650-37F8-464F-93B6-B6AC42E236CB} + EndGlobalSection EndGlobal