Skip to content

Commit 59ded71

Browse files
committed
Allow more types for .In() and .Contains()
1 parent ec908ce commit 59ded71

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/CouchDB.Driver/Extensions/EnumerableExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static class EnumerableExtensions
1313
/// <param name="source">A sequence in which to locate a value.</param>
1414
/// <param name="input">Values to locate in the sequence.</param>
1515
/// <returns>true if the source sequence contains all elements that has specified values; otherwise, false.</returns>
16-
public static bool Contains<T>(this IEnumerable<T> source, IEnumerable<T> input) where T : IConvertible
16+
public static bool Contains<T>(this IEnumerable<T> source, IEnumerable<T> input)
1717
{
1818
if (source == null)
1919
{

src/CouchDB.Driver/Extensions/ObjectExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static class ObjectExtensions
1515
/// <param name="value">The value to locate in the input.</param>
1616
/// <param name="input">A sequence in which to locate the value.</param>
1717
/// <returns>true if the input sequence contains an element that has the specified value; otherwise, false.</returns>
18-
public static bool In<T>(this T value, IEnumerable<T> input) where T : IConvertible
18+
public static bool In<T>(this T value, IEnumerable<T> input)
1919
{
2020
if (value == null)
2121
{

tests/CouchDB.Driver.UnitTests/Find/Find_Selector_Conditions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using CouchDB.Driver.Extensions;
22
using CouchDB.Driver.Types;
33
using CouchDB.Driver.UnitTests.Models;
4+
using System;
45
using Xunit;
56

67
namespace CouchDB.Driver.UnitTests.Find
@@ -81,6 +82,13 @@ public void Array_In()
8182
var json = _rebels.Where(r => r.Age.In(new[] { 20, 30 })).ToString();
8283
Assert.Equal(@"{""selector"":{""age"":{""$in"":[20,30]}}}", json);
8384
}
85+
86+
[Fact]
87+
public void Array_In_Guid()
88+
{
89+
var json = _rebels.Where(r => r.Guid.In(new[] { Guid.Parse("00000000-0000-0000-0000-000000000000"), Guid.Parse("11111111-1111-1111-1111-111111111111") })).ToString();
90+
Assert.Equal(@"{""selector"":{""guid"":{""$in"":[""00000000-0000-0000-0000-000000000000"",""11111111-1111-1111-1111-111111111111""]}}}", json);
91+
}
8492
[Fact]
8593
public void Array_NotIn()
8694
{

0 commit comments

Comments
 (0)