Dependencies: Updates to .NET 10 RC and NPoco 6.1 (#20184)
* Update to .NET 10 RC 1. * Update NPoco to 6.1.0 and resolve binary breaking changes. * Resolved behavioural breaking changes (need to use List<string> over string[] for Contains). * Update dependency on NPoco.SqlServer. * Further fixes from manual testing. * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fixed comment typos. * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fixed nullability issue. * Fix database creation issue * Fix missing to list --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: nikolajlauridsen <nikolajlauridsen@protonmail.ch>
This commit is contained in:
@@ -13,6 +13,7 @@ using Umbraco.Cms.Infrastructure.Persistence;
|
||||
using Umbraco.Cms.Infrastructure.Persistence.Mappers;
|
||||
using Umbraco.Cms.Persistence.SqlServer.Services;
|
||||
using Umbraco.Extensions;
|
||||
using IMapperCollection = Umbraco.Cms.Infrastructure.Persistence.Mappers.IMapperCollection;
|
||||
using MapperCollection = NPoco.MapperCollection;
|
||||
|
||||
namespace Umbraco.Cms.Tests.UnitTests.TestHelpers;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ExpressionTests : BaseUsingSqlSyntax
|
||||
public void Can_Query_With_Content_Type_Aliases_IEnumerable()
|
||||
{
|
||||
// Arrange - Contains is IEnumerable.Contains extension method
|
||||
var aliases = new[] { "Test1", "Test2" };
|
||||
var aliases = new List<string> { "Test1", "Test2" };
|
||||
Expression<Func<IMedia, bool>> predicate = content => aliases.Contains(content.ContentType.Alias);
|
||||
var modelToSqlExpressionHelper = new ModelToSqlExpressionVisitor<IContent>(SqlContext.SqlSyntax, Mappers);
|
||||
var result = modelToSqlExpressionHelper.Visit(predicate);
|
||||
@@ -178,7 +178,14 @@ public class ExpressionTests : BaseUsingSqlSyntax
|
||||
[Test]
|
||||
public void Sql_In()
|
||||
{
|
||||
var userNames = new[] { "hello@world.com", "blah@blah.com" };
|
||||
// This unit test reveals a breaking change for .NET 10 and NPoco.
|
||||
// When a List<string> is used with Contains in an expression, we call bool List<string>.Contains(string), which NPoco translates to SQL IN.
|
||||
// However, if we use string[] with Contains, we call the extension method bool ReadOnlySpan.Contains<string>(string) which
|
||||
// blows up in ExpressionVisitorBase as the method name of "op_Implicit" is unrecognized.
|
||||
// As such we need to ensure we use a List<string and not string[] here (and anywhere we call Contains).
|
||||
|
||||
//var userNames = new[] { "hello@world.com", "blah@blah.com" };
|
||||
var userNames = new List<string> { "hello@world.com", "blah@blah.com" };
|
||||
|
||||
Expression<Func<IUser, bool>> predicate = user => userNames.Contains(user.Username);
|
||||
var modelToSqlExpressionHelper = new ModelToSqlExpressionVisitor<IUser>(SqlContext.SqlSyntax, Mappers);
|
||||
|
||||
Reference in New Issue
Block a user