Skip to content

Commit

Permalink
Updated namespaces in NpgsqlRangeExtensions and NpgsqlNetworkAddressE…
Browse files Browse the repository at this point in the history
…xtensions to match NpgsqlDbFunctionsExtensions. Changed network operation extension methods to use DbFunctions instead of IPAddress/NpgsqlInet per the discussion in #407. Added XML docs to indicate that all of these extension methods throw a NotSupportedException outside of EF Core.
  • Loading branch information
austindrenski committed May 17, 2018
1 parent 5394545 commit 7254cbf
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 43 deletions.
28 changes: 23 additions & 5 deletions src/EFCore.PG/NpgsqlNetworkAddressExtensions.cs
Expand Up @@ -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
{
/// <summary>
/// Provides extension methods supporting PostgreSQL network address operator translation.
Expand All @@ -37,41 +39,57 @@ public static class NpgsqlNetworkAddressExtensions
/// <summary>
/// Determines whether an <see cref="IPAddress"/> contains another <see cref="IPAddress"/>.
/// </summary>
/// <param name="_">The DbFunctions instance.</param>
/// <param name="ipAddress">The IP address to search.</param>
/// <param name="other">The IP address to locate.</param>
/// <returns>
/// <value>true</value> if the <see cref="IPAddress"/> contains the other <see cref="IPAddress"/>; otherwise, <value>false</value>.
/// </returns>
public static bool Contains(this IPAddress ipAddress, IPAddress other) => throw new NotImplementedException();
/// <exception cref="NotSupportedException">
/// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
/// </exception>
public static bool Contains([CanBeNull] this DbFunctions _, [CanBeNull] IPAddress ipAddress, [CanBeNull] IPAddress other) => throw new NotSupportedException();

/// <summary>
/// Determines whether an <see cref="NpgsqlInet"/> contains another <see cref="NpgsqlInet"/>.
/// </summary>
/// <param name="_">The DbFunctions instance.</param>
/// <param name="inet">The inet to search.</param>
/// <param name="other">The inet to locate.</param>
/// <returns>
/// <value>true</value> if the <see cref="NpgsqlInet"/> contains the other <see cref="NpgsqlInet"/>; otherwise, <value>false</value>.
/// </returns>
public static bool Contains(this NpgsqlInet inet, NpgsqlInet other) => throw new NotImplementedException();
/// <exception cref="NotSupportedException">
/// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
/// </exception>
public static bool Contains([CanBeNull] this DbFunctions _, NpgsqlInet inet, NpgsqlInet other) => throw new NotSupportedException();

/// <summary>
/// Determines whether an <see cref="IPAddress"/> contains or is equal to another <see cref="IPAddress"/>.
/// </summary>
/// <param name="_">The DbFunctions instance.</param>
/// <param name="ipAddress">The IP address to search.</param>
/// <param name="other">The IP address to locate.</param>
/// <returns>
/// <value>true</value> if the <see cref="IPAddress"/> contains or is equal to the other <see cref="IPAddress"/>; otherwise, <value>false</value>.
/// </returns>
public static bool ContainsOrEquals(this IPAddress ipAddress, IPAddress other) => throw new NotImplementedException();
/// <exception cref="NotSupportedException">
/// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
/// </exception>
public static bool ContainsOrEquals([CanBeNull] this DbFunctions _, [CanBeNull] IPAddress ipAddress, [CanBeNull] IPAddress other) => throw new NotSupportedException();

/// <summary>
/// Determines whether an <see cref="NpgsqlInet"/> contains or is equal to another <see cref="NpgsqlInet"/>.
/// </summary>
/// <param name="_">The DbFunctions instance.</param>
/// <param name="inet">The inet to search.</param>
/// <param name="other">The inet to locate.</param>
/// <returns>
/// <value>true</value> if the <see cref="NpgsqlInet"/> contains or is equal to the other <see cref="NpgsqlInet"/>; otherwise, <value>false</value>.
/// </returns>
public static bool ContainsOrEquals(this NpgsqlInet inet, NpgsqlInet other) => throw new NotImplementedException();
/// <exception cref="NotSupportedException">
/// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
/// </exception>
public static bool ContainsOrEquals([CanBeNull] this DbFunctions _, NpgsqlInet inet, NpgsqlInet other) => throw new NotSupportedException();
}
}
39 changes: 38 additions & 1 deletion src/EFCore.PG/NpgsqlRangeExtensions.cs
Expand Up @@ -26,7 +26,8 @@
using System;
using NpgsqlTypes;

namespace Npgsql.EntityFrameworkCore.PostgreSQL
// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
/// <summary>
/// Provides extension methods for <see cref="NpgsqlRange{T}"/> supporting PostgreSQL translation.
Expand All @@ -42,6 +43,9 @@ public static class NpgsqlRangeExtensions
/// <returns>
/// <value>true</value> if the range contains the specified value; otherwise, <value>false</value>.
/// </returns>
/// <exception cref="NotSupportedException">
/// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
/// </exception>
public static bool Contains<T>(this NpgsqlRange<T> range, T value) where T : IComparable<T> => throw new NotSupportedException();

/// <summary>
Expand All @@ -53,6 +57,9 @@ public static class NpgsqlRangeExtensions
/// <returns>
/// <value>true</value> if the range contains the specified range; otherwise, <value>false</value>.
/// </returns>
/// <exception cref="NotSupportedException">
/// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
/// </exception>
public static bool Contains<T>(this NpgsqlRange<T> a, NpgsqlRange<T> b) where T : IComparable<T> => throw new NotSupportedException();

/// <summary>
Expand All @@ -64,6 +71,9 @@ public static class NpgsqlRangeExtensions
/// <returns>
/// <value>true</value> if the range contains the specified range; otherwise, <value>false</value>.
/// </returns>
/// <exception cref="NotSupportedException">
/// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
/// </exception>
public static bool ContainedBy<T>(this NpgsqlRange<T> a, NpgsqlRange<T> b) where T : IComparable<T> => b.Contains(a);

/// <summary>
Expand All @@ -75,6 +85,9 @@ public static class NpgsqlRangeExtensions
/// <returns>
/// <value>true</value> if the ranges overlap (share points in common); otherwise, <value>false</value>.
/// </returns>
/// <exception cref="NotSupportedException">
/// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
/// </exception>
public static bool Overlaps<T>(this NpgsqlRange<T> a, NpgsqlRange<T> b) where T : IComparable<T> => throw new NotSupportedException();

/// <summary>
Expand All @@ -86,6 +99,9 @@ public static class NpgsqlRangeExtensions
/// <returns>
/// <value>true</value> if the first range is strictly to the left of the second; otherwise, <value>false</value>.
/// </returns>
/// <exception cref="NotSupportedException">
/// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
/// </exception>
public static bool IsStrictlyLeftOf<T>(this NpgsqlRange<T> a, NpgsqlRange<T> b) where T : IComparable<T> => throw new NotSupportedException();

/// <summary>
Expand All @@ -97,6 +113,9 @@ public static class NpgsqlRangeExtensions
/// <returns>
/// <value>true</value> if the first range is strictly to the right of the second; otherwise, <value>false</value>.
/// </returns>
/// <exception cref="NotSupportedException">
/// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
/// </exception>
public static bool IsStrictlyRightOf<T>(this NpgsqlRange<T> a, NpgsqlRange<T> b) where T : IComparable<T> => throw new NotSupportedException();

/// <summary>
Expand All @@ -108,6 +127,9 @@ public static class NpgsqlRangeExtensions
/// <returns>
/// <value>true</value> if the first range does not extend to the left of the second; otherwise, <value>false</value>.
/// </returns>
/// <exception cref="NotSupportedException">
/// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
/// </exception>
public static bool DoesNotExtendLeftOf<T>(this NpgsqlRange<T> a, NpgsqlRange<T> b) where T : IComparable<T> => throw new NotSupportedException();

/// <summary>
Expand All @@ -119,6 +141,9 @@ public static class NpgsqlRangeExtensions
/// <returns>
/// <value>true</value> if the first range does not extend to the right of the second; otherwise, <value>false</value>.
/// </returns>
/// <exception cref="NotSupportedException">
/// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
/// </exception>
public static bool DoesNotExtendRightOf<T>(this NpgsqlRange<T> a, NpgsqlRange<T> b) where T : IComparable<T> => throw new NotSupportedException();

/// <summary>
Expand All @@ -130,6 +155,9 @@ public static class NpgsqlRangeExtensions
/// <returns>
/// <value>true</value> if the ranges are adjacent; otherwise, <value>false</value>.
/// </returns>
/// <exception cref="NotSupportedException">
/// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
/// </exception>
public static bool IsAdjacentTo<T>(this NpgsqlRange<T> a, NpgsqlRange<T> b) where T : IComparable<T> => throw new NotSupportedException();

/// <summary>
Expand All @@ -141,6 +169,9 @@ public static class NpgsqlRangeExtensions
/// <returns>
/// The unique elements that appear in either range.
/// </returns>
/// <exception cref="NotSupportedException">
/// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
/// </exception>
public static NpgsqlRange<T> Union<T>(this NpgsqlRange<T> a, NpgsqlRange<T> b) where T : IComparable<T> => throw new NotSupportedException();

/// <summary>
Expand All @@ -152,6 +183,9 @@ public static class NpgsqlRangeExtensions
/// <returns>
/// The elements that appear in both ranges.
/// </returns>
/// <exception cref="NotSupportedException">
/// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
/// </exception>
public static NpgsqlRange<T> Intersect<T>(this NpgsqlRange<T> a, NpgsqlRange<T> b) where T : IComparable<T> => throw new NotSupportedException();

/// <summary>
Expand All @@ -163,6 +197,9 @@ public static class NpgsqlRangeExtensions
/// <returns>
/// The elements that appear in the first range, but not the second range.
/// </returns>
/// <exception cref="NotSupportedException">
/// This method is only intended for use via SQL translation as part of an EF Core LINQ query.
/// </exception>
public static NpgsqlRange<T> Except<T>(this NpgsqlRange<T> a, NpgsqlRange<T> b) where T : IComparable<T> => throw new NotSupportedException();
}
}

0 comments on commit 7254cbf

Please sign in to comment.