Moves SqlNullableEquals to SqlExpressionExtensions

This commit is contained in:
Shannon
2018-12-06 01:14:06 +11:00
parent a239d50e89
commit 85efd4dc59
3 changed files with 17 additions and 15 deletions

View File

@@ -788,19 +788,6 @@ namespace Umbraco.Core
return BoolConvertCache[type] = false;
}
/// <summary>
/// Indicates whether two nullable values are equal, substituting a fallback value for nulls.
/// </summary>
/// <typeparam name="T">The nullable type.</typeparam>
/// <param name="value">The value to compare.</param>
/// <param name="other">The value to compare to.</param>
/// <param name="fallbackValue">The value to use when any value is null.</param>
/// <remarks>Do not use outside of Sql expressions.</remarks>
// see usage in ExpressionVisitorBase
public static bool SqlNullableEquals<T>(this T? value, T? other, T fallbackValue)
where T : struct
{
return (value ?? fallbackValue).Equals(other ?? fallbackValue);
}
}
}

View File

@@ -9,6 +9,21 @@ namespace Umbraco.Core.Persistence.Querying
/// </summary>
internal static class SqlExpressionExtensions
{
/// <summary>
/// Indicates whether two nullable values are equal, substituting a fallback value for nulls.
/// </summary>
/// <typeparam name="T">The nullable type.</typeparam>
/// <param name="value">The value to compare.</param>
/// <param name="other">The value to compare to.</param>
/// <param name="fallbackValue">The value to use when any value is null.</param>
/// <remarks>Do not use outside of Sql expressions.</remarks>
// see usage in ExpressionVisitorBase
public static bool SqlNullableEquals<T>(this T? value, T? other, T fallbackValue)
where T : struct
{
return (value ?? fallbackValue).Equals(other ?? fallbackValue);
}
public static bool SqlIn<T>(this IEnumerable<T> collection, T item)
{
return collection.Contains(item);

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic;
using NPoco;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Dtos;
using Umbraco.Tests.TestHelpers;