diff --git a/src/EFCore.PG/Extensions/NpgsqlRangeExtensions.cs b/src/EFCore.PG/Extensions/NpgsqlRangeExtensions.cs
index 8f3821c903..3bdf2688af 100644
--- a/src/EFCore.PG/Extensions/NpgsqlRangeExtensions.cs
+++ b/src/EFCore.PG/Extensions/NpgsqlRangeExtensions.cs
@@ -43,6 +43,9 @@ public static class NpgsqlRangeExtensions
///
/// true if the range contains the specified value; otherwise, false.
///
+ ///
+ /// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
+ ///
public static bool Contains(this NpgsqlRange range, T value) where T : IComparable => throw new NotSupportedException();
///
@@ -54,6 +57,9 @@ public static class NpgsqlRangeExtensions
///
/// true if the range contains the specified range; otherwise, false.
///
+ ///
+ /// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
+ ///
public static bool Contains(this NpgsqlRange a, NpgsqlRange b) where T : IComparable => throw new NotSupportedException();
///
@@ -65,6 +71,9 @@ public static class NpgsqlRangeExtensions
///
/// true if the range contains the specified range; otherwise, false.
///
+ ///
+ /// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
+ ///
public static bool ContainedBy(this NpgsqlRange a, NpgsqlRange b) where T : IComparable => b.Contains(a);
///
@@ -76,6 +85,9 @@ public static class NpgsqlRangeExtensions
///
/// true if the ranges overlap (share points in common); otherwise, false.
///
+ ///
+ /// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
+ ///
public static bool Overlaps(this NpgsqlRange a, NpgsqlRange b) where T : IComparable => throw new NotSupportedException();
///
@@ -87,6 +99,9 @@ public static class NpgsqlRangeExtensions
///
/// true if the first range is strictly to the left of the second; otherwise, false.
///
+ ///
+ /// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
+ ///
public static bool IsStrictlyLeftOf(this NpgsqlRange a, NpgsqlRange b) where T : IComparable => throw new NotSupportedException();
///
@@ -98,6 +113,9 @@ public static class NpgsqlRangeExtensions
///
/// true if the first range is strictly to the right of the second; otherwise, false.
///
+ ///
+ /// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
+ ///
public static bool IsStrictlyRightOf(this NpgsqlRange a, NpgsqlRange b) where T : IComparable => throw new NotSupportedException();
///
@@ -109,6 +127,9 @@ public static class NpgsqlRangeExtensions
///
/// true if the first range does not extend to the left of the second; otherwise, false.
///
+ ///
+ /// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
+ ///
public static bool DoesNotExtendLeftOf(this NpgsqlRange a, NpgsqlRange b) where T : IComparable => throw new NotSupportedException();
///
@@ -120,6 +141,9 @@ public static class NpgsqlRangeExtensions
///
/// true if the first range does not extend to the right of the second; otherwise, false.
///
+ ///
+ /// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
+ ///
public static bool DoesNotExtendRightOf(this NpgsqlRange a, NpgsqlRange b) where T : IComparable => throw new NotSupportedException();
///
@@ -131,6 +155,9 @@ public static class NpgsqlRangeExtensions
///
/// true if the ranges are adjacent; otherwise, false.
///
+ ///
+ /// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
+ ///
public static bool IsAdjacentTo(this NpgsqlRange a, NpgsqlRange b) where T : IComparable => throw new NotSupportedException();
///
@@ -142,6 +169,9 @@ public static class NpgsqlRangeExtensions
///
/// The unique elements that appear in either range.
///
+ ///
+ /// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
+ ///
public static NpgsqlRange Union(this NpgsqlRange a, NpgsqlRange b) where T : IComparable => throw new NotSupportedException();
///
@@ -153,6 +183,9 @@ public static class NpgsqlRangeExtensions
///
/// The elements that appear in both ranges.
///
+ ///
+ /// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
+ ///
public static NpgsqlRange Intersect(this NpgsqlRange a, NpgsqlRange b) where T : IComparable => throw new NotSupportedException();
///
@@ -164,6 +197,9 @@ public static class NpgsqlRangeExtensions
///
/// The elements that appear in the first range, but not the second range.
///
+ ///
+ /// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
+ ///
public static NpgsqlRange Except(this NpgsqlRange a, NpgsqlRange b) where T : IComparable => throw new NotSupportedException();
}
}
diff --git a/src/EFCore.PG/NpgsqlNetworkAddressExtensions.cs b/src/EFCore.PG/NpgsqlNetworkAddressExtensions.cs
index d51f9ea9dc..12ae0cef23 100644
--- a/src/EFCore.PG/NpgsqlNetworkAddressExtensions.cs
+++ b/src/EFCore.PG/NpgsqlNetworkAddressExtensions.cs
@@ -25,9 +25,11 @@
using System;
using System.Net;
+using JetBrains.Annotations;
using NpgsqlTypes;
-namespace Npgsql.EntityFrameworkCore.PostgreSQL
+// ReSharper disable once CheckNamespace
+namespace Microsoft.EntityFrameworkCore
{
///
/// Provides extension methods supporting PostgreSQL network address operator translation.
@@ -37,41 +39,57 @@ public static class NpgsqlNetworkAddressExtensions
///
/// Determines whether an contains another .
///
+ /// The DbFunctions instance.
/// The IP address to search.
/// The IP address to locate.
///
/// true if the contains the other ; otherwise, false.
///
- public static bool Contains(this IPAddress ipAddress, IPAddress other) => throw new NotImplementedException();
+ ///
+ /// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
+ ///
+ public static bool Contains([CanBeNull] this DbFunctions _, [CanBeNull] IPAddress ipAddress, [CanBeNull] IPAddress other) => throw new NotSupportedException();
///
/// Determines whether an contains another .
///
+ /// The DbFunctions instance.
/// The inet to search.
/// The inet to locate.
///
/// true if the contains the other ; otherwise, false.
///
- public static bool Contains(this NpgsqlInet inet, NpgsqlInet other) => throw new NotImplementedException();
+ ///
+ /// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
+ ///
+ public static bool Contains([CanBeNull] this DbFunctions _, NpgsqlInet inet, NpgsqlInet other) => throw new NotSupportedException();
///
/// Determines whether an contains or is equal to another .
///
+ /// The DbFunctions instance.
/// The IP address to search.
/// The IP address to locate.
///
/// true if the contains or is equal to the other ; otherwise, false.
///
- public static bool ContainsOrEquals(this IPAddress ipAddress, IPAddress other) => throw new NotImplementedException();
+ ///
+ /// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
+ ///
+ public static bool ContainsOrEquals([CanBeNull] this DbFunctions _, [CanBeNull] IPAddress ipAddress, [CanBeNull] IPAddress other) => throw new NotSupportedException();
///
/// Determines whether an contains or is equal to another .
///
+ /// The DbFunctions instance.
/// The inet to search.
/// The inet to locate.
///
/// true if the contains or is equal to the other ; otherwise, false.
///
- public static bool ContainsOrEquals(this NpgsqlInet inet, NpgsqlInet other) => throw new NotImplementedException();
+ ///
+ /// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
+ ///
+ public static bool ContainsOrEquals([CanBeNull] this DbFunctions _, NpgsqlInet inet, NpgsqlInet other) => throw new NotSupportedException();
}
}
diff --git a/test/EFCore.PG.FunctionalTests/Query/NetworkAddressQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NetworkAddressQueryNpgsqlTest.cs
index 76029f399f..71543694e3 100644
--- a/test/EFCore.PG.FunctionalTests/Query/NetworkAddressQueryNpgsqlTest.cs
+++ b/test/EFCore.PG.FunctionalTests/Query/NetworkAddressQueryNpgsqlTest.cs
@@ -36,7 +36,28 @@ public NetworkAddressQueryNpgsqlTest(NetworkAddressQueryNpgsqlFixture fixture)
#region Tests
///
- /// Tests translation for .
+ /// Demonstrates parameter duplication.
+ ///
+ [Fact(Skip = nameof(NetworkAddressQueryNpgsqlTest))]
+ public void Demonstrate_ValueTypeParametersAreDuplicated()
+ {
+ using (NetContext context = Fixture.CreateContext())
+ {
+ NpgsqlInet npgsqlInet = new IPAddress(0);
+
+ bool[] _ =
+ context.NetTestEntities
+ .Where(x => EF.Functions.ContainsOrEquals(x.CidrMappedToNpgsqlInet, npgsqlInet))
+ .Select(x => x.CidrMappedToNpgsqlInet.Equals(npgsqlInet))
+ .ToArray();
+
+ AssertContainsSql("SELECT x.\"CidrMappedToNpgsqlInet\" = @__npgsqlInet_0");
+ AssertContainsSql("WHERE x.\"CidrMappedToNpgsqlInet\" >>= @__npgsqlInet_0");
+ }
+ }
+
+ ///
+ /// Tests translation for .
///
[Fact]
public void IPAddressContainsIPAddress()
@@ -47,7 +68,7 @@ public void IPAddressContainsIPAddress()
NetTestEntity[] _ =
context.NetTestEntities
- .Where(x => x.InetMappedToIPAddress.Contains(address))
+ .Where(x => EF.Functions.Contains(x.InetMappedToIPAddress, address))
.ToArray();
AssertContainsSql("WHERE x.\"InetMappedToIPAddress\" >> @__address_0");
@@ -55,7 +76,7 @@ public void IPAddressContainsIPAddress()
}
///
- /// Tests translation for .
+ /// Tests translation for .
///
[Fact]
public void NpgsqlInetContainsNpgsqlInet()
@@ -66,7 +87,7 @@ public void NpgsqlInetContainsNpgsqlInet()
NetTestEntity[] _ =
context.NetTestEntities
- .Where(x => x.CidrMappedToNpgsqlInet.Contains(npgsqlInet))
+ .Where(x => EF.Functions.Contains(x.CidrMappedToNpgsqlInet, npgsqlInet))
.ToArray();
AssertContainsSql("WHERE x.\"CidrMappedToNpgsqlInet\" >> @__npgsqlInet_0");
@@ -74,7 +95,7 @@ public void NpgsqlInetContainsNpgsqlInet()
}
///
- /// Tests inverse translation for .
+ /// Tests inverse translation for .
///
[Fact]
public void IPAddressDoesNotContainsIPAddress()
@@ -85,7 +106,7 @@ public void IPAddressDoesNotContainsIPAddress()
NetTestEntity[] _ =
context.NetTestEntities
- .Where(x => !x.InetMappedToIPAddress.Contains(address))
+ .Where(x => !EF.Functions.Contains(x.InetMappedToIPAddress, address))
.ToArray();
AssertContainsSql("WHERE NOT (x.\"InetMappedToIPAddress\" >> @__address_0 = TRUE)");
@@ -93,7 +114,7 @@ public void IPAddressDoesNotContainsIPAddress()
}
///
- /// Tests inverse translation for .
+ /// Tests inverse translation for .
///
[Fact]
public void NpgsqlInetDoesNotContainNpgsqlInet()
@@ -104,7 +125,7 @@ public void NpgsqlInetDoesNotContainNpgsqlInet()
NetTestEntity[] _ =
context.NetTestEntities
- .Where(x => !x.CidrMappedToNpgsqlInet.Contains(npgsqlInet))
+ .Where(x => !EF.Functions.Contains(x.CidrMappedToNpgsqlInet, npgsqlInet))
.ToArray();
AssertContainsSql("WHERE NOT (x.\"CidrMappedToNpgsqlInet\" >> @__npgsqlInet_0 = TRUE)");
@@ -112,7 +133,7 @@ public void NpgsqlInetDoesNotContainNpgsqlInet()
}
///
- /// Tests translation for .
+ /// Tests translation for .
///
[Fact]
public void IPAddressContainOrEqualIPAddress()
@@ -123,7 +144,7 @@ public void IPAddressContainOrEqualIPAddress()
NetTestEntity[] _ =
context.NetTestEntities
- .Where(x => x.InetMappedToIPAddress.ContainsOrEquals(address))
+ .Where(x => EF.Functions.ContainsOrEquals(x.InetMappedToIPAddress, address))
.ToArray();
AssertContainsSql("WHERE x.\"InetMappedToIPAddress\" >>= @__address_0");
@@ -131,7 +152,7 @@ public void IPAddressContainOrEqualIPAddress()
}
///
- /// Tests translation for .
+ /// Tests translation for .
///
[Fact]
public void NpgsqlInetContainsOrEqualsNpgsqlInet()
@@ -142,7 +163,7 @@ public void NpgsqlInetContainsOrEqualsNpgsqlInet()
NetTestEntity[] _ =
context.NetTestEntities
- .Where(x => x.CidrMappedToNpgsqlInet.ContainsOrEquals(npgsqlInet))
+ .Where(x => EF.Functions.ContainsOrEquals(x.CidrMappedToNpgsqlInet, npgsqlInet))
.ToArray();
AssertContainsSql("WHERE x.\"CidrMappedToNpgsqlInet\" >>= @__npgsqlInet_0");
@@ -150,7 +171,7 @@ public void NpgsqlInetContainsOrEqualsNpgsqlInet()
}
///
- /// Tests inverse translation for .
+ /// Tests inverse translation for .
///
[Fact]
public void IPAddressDoesNotContainOrEqualIPAddress()
@@ -161,7 +182,7 @@ public void IPAddressDoesNotContainOrEqualIPAddress()
NetTestEntity[] _ =
context.NetTestEntities
- .Where(x => !x.InetMappedToIPAddress.ContainsOrEquals(address))
+ .Where(x => !EF.Functions.ContainsOrEquals(x.InetMappedToIPAddress, address))
.ToArray();
AssertContainsSql("WHERE NOT (x.\"InetMappedToIPAddress\" >>= @__address_0 = TRUE)");
@@ -169,7 +190,7 @@ public void IPAddressDoesNotContainOrEqualIPAddress()
}
///
- /// Tests inverse translation for .
+ /// Tests inverse translation for .
///
[Fact]
public void NpgsqlInetDoesNotContainOrEqualNpgsqlInet()
@@ -180,34 +201,13 @@ public void NpgsqlInetDoesNotContainOrEqualNpgsqlInet()
NetTestEntity[] _ =
context.NetTestEntities
- .Where(x => !x.CidrMappedToNpgsqlInet.ContainsOrEquals(npgsqlInet))
+ .Where(x => !EF.Functions.ContainsOrEquals(x.CidrMappedToNpgsqlInet, npgsqlInet))
.ToArray();
AssertContainsSql("WHERE NOT (x.\"CidrMappedToNpgsqlInet\" >>= @__npgsqlInet_0 = TRUE)");
}
}
- ///
- /// Tests inverse translation for .
- ///
- [Fact]
- public void Demonstrate_ValueTypeParametersAreDuplicated()
- {
- using (NetContext context = Fixture.CreateContext())
- {
- NpgsqlInet npgsqlInet = new IPAddress(0);
-
- bool[] _ =
- context.NetTestEntities
- .Where(x => x.CidrMappedToNpgsqlInet.ContainsOrEquals(npgsqlInet))
- .Select(x => x.CidrMappedToNpgsqlInet.Equals(npgsqlInet))
- .ToArray();
-
- AssertContainsSql("SELECT x.\"CidrMappedToNpgsqlInet\" = @__npgsqlInet_0");
- AssertContainsSql("WHERE x.\"CidrMappedToNpgsqlInet\" >>= @__npgsqlInet_0");
- }
- }
-
#endregion
#region Fixtures