diff --git a/Directory.Packages.props b/Directory.Packages.props index df290bc6d..1794fab92 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -22,7 +22,8 @@ - + + diff --git a/benchmarks/Dapper.Tests.Performance/Benchmarks.Linq2DB.cs b/benchmarks/Dapper.Tests.Performance/Benchmarks.Linq2DB.cs index cb9aaacd2..b9ff56a61 100644 --- a/benchmarks/Dapper.Tests.Performance/Benchmarks.Linq2DB.cs +++ b/benchmarks/Dapper.Tests.Performance/Benchmarks.Linq2DB.cs @@ -44,5 +44,22 @@ public Post Query() Step(); return _dbContext.Query("select * from Posts where Id = @id", new { id = i }).First(); } + + [Benchmark(Description = "FirstOrDefault (v6 optimized)")] + public Post FirstOrDefault() + { + Step(); + return _dbContext.Posts.FirstOrDefault(p => p.Id == i); + } + +#if NET6_0_OR_GREATER + // MaxBy is a new LINQ operator supported in linq2db v6.x for .NET 6+ + [Benchmark(Description = "MaxBy (v6 new operator)")] + public Post MaxByCreationDate() + { + Step(); + return _dbContext.Posts.Where(p => p.Id <= i).MaxBy(p => p.CreationDate); + } +#endif } } diff --git a/benchmarks/Dapper.Tests.Performance/Dapper.Tests.Performance.csproj b/benchmarks/Dapper.Tests.Performance/Dapper.Tests.Performance.csproj index 78dd70c0a..40395f837 100644 --- a/benchmarks/Dapper.Tests.Performance/Dapper.Tests.Performance.csproj +++ b/benchmarks/Dapper.Tests.Performance/Dapper.Tests.Performance.csproj @@ -16,6 +16,7 @@ + diff --git a/benchmarks/Dapper.Tests.Performance/Post.cs b/benchmarks/Dapper.Tests.Performance/Post.cs index 514f24ee1..3d26d050a 100644 --- a/benchmarks/Dapper.Tests.Performance/Post.cs +++ b/benchmarks/Dapper.Tests.Performance/Post.cs @@ -8,29 +8,43 @@ public class Post { [LinqToDB.Mapping.PrimaryKey, LinqToDB.Mapping.Identity] public int Id { get; set; } - [LinqToDB.Mapping.Column, LinqToDB.Mapping.Nullable] + + // In v6.x, nullability is inferred from the type, so Nullable/NotNull attributes are optional + [LinqToDB.Mapping.Column] public string Text { get; set; } - [LinqToDB.Mapping.Column, LinqToDB.Mapping.NotNull] + + [LinqToDB.Mapping.Column] public DateTime CreationDate { get; set; } - [LinqToDB.Mapping.Column, LinqToDB.Mapping.NotNull] + + [LinqToDB.Mapping.Column] public DateTime LastChangeDate { get; set; } - [LinqToDB.Mapping.Column, LinqToDB.Mapping.Nullable] + + // Nullable value types automatically infer nullability in v6.x + [LinqToDB.Mapping.Column] public int? Counter1 { get; set; } - [LinqToDB.Mapping.Column, LinqToDB.Mapping.Nullable] + + [LinqToDB.Mapping.Column] public int? Counter2 { get; set; } - [LinqToDB.Mapping.Column, LinqToDB.Mapping.Nullable] + + [LinqToDB.Mapping.Column] public int? Counter3 { get; set; } - [LinqToDB.Mapping.Column, LinqToDB.Mapping.Nullable] + + [LinqToDB.Mapping.Column] public int? Counter4 { get; set; } - [LinqToDB.Mapping.Column, LinqToDB.Mapping.Nullable] + + [LinqToDB.Mapping.Column] public int? Counter5 { get; set; } - [LinqToDB.Mapping.Column, LinqToDB.Mapping.Nullable] + + [LinqToDB.Mapping.Column] public int? Counter6 { get; set; } - [LinqToDB.Mapping.Column, LinqToDB.Mapping.Nullable] + + [LinqToDB.Mapping.Column] public int? Counter7 { get; set; } - [LinqToDB.Mapping.Column, LinqToDB.Mapping.Nullable] + + [LinqToDB.Mapping.Column] public int? Counter8 { get; set; } - [LinqToDB.Mapping.Column, LinqToDB.Mapping.Nullable] + + [LinqToDB.Mapping.Column] public int? Counter9 { get; set; } } }