diff --git a/Directory.Packages.props b/Directory.Packages.props
index 4ddd3896f..01200e689 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -9,7 +9,8 @@
-
+
+
@@ -37,10 +38,13 @@
-
+
-
+
+
+
+
\ No newline at end of file
diff --git a/benchmarks/Dapper.Tests.Performance/Benchmarks.EntityFrameworkCore.cs b/benchmarks/Dapper.Tests.Performance/Benchmarks.EntityFrameworkCore.cs
index 2c8b811b2..5fb68cc49 100644
--- a/benchmarks/Dapper.Tests.Performance/Benchmarks.EntityFrameworkCore.cs
+++ b/benchmarks/Dapper.Tests.Performance/Benchmarks.EntityFrameworkCore.cs
@@ -3,6 +3,7 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel;
+using System.Data.SqlClient;
using System.Linq;
namespace Dapper.Tests.Performance
@@ -19,7 +20,8 @@ public class EFCoreBenchmarks : BenchmarkBase
public void Setup()
{
BaseSetup();
- Context = new EFCoreContext(ConnectionString);
+ var connBuilder = new SqlConnectionStringBuilder(ConnectionString) { TrustServerCertificate = true };
+ Context = new EFCoreContext(connBuilder.ConnectionString);
}
[Benchmark(Description = "First")]
diff --git a/benchmarks/Dapper.Tests.Performance/Benchmarks.Nextorm.cs b/benchmarks/Dapper.Tests.Performance/Benchmarks.Nextorm.cs
new file mode 100644
index 000000000..92f72457d
--- /dev/null
+++ b/benchmarks/Dapper.Tests.Performance/Benchmarks.Nextorm.cs
@@ -0,0 +1,103 @@
+#if !NET4X
+using System.ComponentModel;
+using System.Linq;
+using BenchmarkDotNet.Attributes;
+using Microsoft.Extensions.Logging;
+using nextorm.core;
+using nextorm.sqlserver;
+
+namespace Dapper.Tests.Performance;
+
+[Description("Nextorm")]
+public class NextormBenchmarks : BenchmarkBase
+{
+ private NextormRepository _repository;
+ private IPreparedQueryCommand _getPostByIdPrepared;
+ private QueryCommand _getPostById;
+ private IPreparedQueryCommand _queryBufferedPrepared;
+ private IPreparedQueryCommand _queryUnbufferedPrepared;
+
+ [GlobalSetup]
+ public void GlobalSetup() => Setup(false);
+ public void Setup(bool withLogging)
+ {
+ BaseSetup();
+ var builder = new DbContextBuilder();
+ builder.UseSqlServer(_connection);
+ if (withLogging)
+ {
+ var logFactory = LoggerFactory.Create(config => config.AddConsole().SetMinimumLevel(LogLevel.Debug));
+ builder.UseLoggerFactory(logFactory);
+ builder.LogSensitiveData(true);
+ }
+
+ _repository = new NextormRepository(builder);
+
+ var cmdBuilder = _repository.Posts.Where(it => it.Id == NORM.Param(0));
+ _queryBufferedPrepared = cmdBuilder.ToCommand().Prepare();
+ _queryUnbufferedPrepared = cmdBuilder.ToCommand().Prepare(false);
+ _getPostById = cmdBuilder.FirstOrFirstOrDefaultCommand();
+ _getPostByIdPrepared = _getPostById.Prepare();
+ }
+ [Benchmark(Description = "QueryFirstOrDefault")]
+ public Post First()
+ {
+ Step();
+ return _repository.Posts.Where(it => it.Id == i).FirstOrDefault();
+ }
+ [Benchmark(Description = "Query (buffered)")]
+ public Post QueryBuffered()
+ {
+ Step();
+ return _repository.Posts.Where(it => it.Id == i).ToList().FirstOrDefault();
+ }
+ [Benchmark(Description = "Query (unbuffered)")]
+ public Post QueryUnbuffered()
+ {
+ Step();
+ return _repository.Posts.Where(it => it.Id == i).ToEnumerable().FirstOrDefault();
+ }
+ [Benchmark(Description = "QueryFirstOrDefault with param")]
+ public Post FirstParam()
+ {
+ Step();
+ return _getPostById.FirstOrDefault(i);
+ }
+
+ [Benchmark(Description = "QueryFirstOrDefault prepared")]
+ public Post FirstPrepared()
+ {
+ Step();
+ return _getPostByIdPrepared.FirstOrDefault(_repository.DataContext, i);
+ }
+ [Benchmark(Description = "Query (buffered prepared)")]
+ public Post QueryBufferedPrepared()
+ {
+ Step();
+ return _queryBufferedPrepared.ToList(_repository.DataContext, i).FirstOrDefault();
+ }
+ [Benchmark(Description = "Query (unbuffered prepared)")]
+ public Post QueryUnbufferedPrepared()
+ {
+ Step();
+ return _queryUnbufferedPrepared.ToEnumerable(_repository.DataContext, i).FirstOrDefault();
+ }
+}
+
+public class NextormRepository
+{
+ private readonly IDataContext _dataContext;
+
+ public NextormRepository(DbContextBuilder builder) : this(builder.CreateDbContext())
+ {
+ }
+ public NextormRepository(IDataContext dataContext)
+ {
+ Posts = dataContext.Create(config => config.Table("posts"));
+ _dataContext = dataContext;
+ }
+
+ public Entity Posts { get; set; }
+ public IDataContext DataContext => _dataContext;
+}
+#endif
diff --git a/benchmarks/Dapper.Tests.Performance/Dapper.Tests.Performance.csproj b/benchmarks/Dapper.Tests.Performance/Dapper.Tests.Performance.csproj
index 52396c03e..db800004d 100644
--- a/benchmarks/Dapper.Tests.Performance/Dapper.Tests.Performance.csproj
+++ b/benchmarks/Dapper.Tests.Performance/Dapper.Tests.Performance.csproj
@@ -14,7 +14,7 @@
-
+
@@ -33,7 +33,7 @@
-
+
$(DefineConstants);NET4X
@@ -48,7 +48,13 @@
-
+
+
+
+
+
+
+