Skip to content

Commit 353cdb0

Browse files
committed
CSHARP-1583: Resolve ambiguous overloads in MongoQueryable.
1 parent 65e8bfb commit 353cdb0

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

src/MongoDB.Driver.Tests/Linq/MongoQueryableTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2010-2015 MongoDB Inc.
1+
/* Copyright 2010-2016 MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -19,11 +19,13 @@
1919
using System.Threading.Tasks;
2020
using FluentAssertions;
2121
using MongoDB.Bson;
22+
using MongoDB.Driver;
2223
using MongoDB.Driver.Core;
2324
using MongoDB.Driver.Linq;
25+
using MongoDB.Driver.Tests.Linq;
2426
using NUnit.Framework;
2527

26-
namespace MongoDB.Driver.Tests.Linq
28+
namespace Tests.MongoDB.Driver.Linq
2729
{
2830
[TestFixture]
2931
public class MongoQueryableTests : IntegrationTestBase

src/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
55
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

src/MongoDB.Driver/Linq/MongoQueryable.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ public static IMongoQueryable<TSource> Distinct<TSource>(this IMongoQueryable<TS
486486
/// <returns>
487487
/// The first element in <paramref name="source" />.
488488
/// </returns>
489-
public static Task<TSource> FirstAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = default(CancellationToken))
489+
public static Task<TSource> FirstAsync<TSource>(this IMongoQueryable<TSource> source, CancellationToken cancellationToken = default(CancellationToken))
490490
{
491491
return ((IMongoQueryProvider)source.Provider).ExecuteAsync<TSource>(
492492
Expression.Call(
@@ -505,7 +505,7 @@ public static IMongoQueryable<TSource> Distinct<TSource>(this IMongoQueryable<TS
505505
/// <returns>
506506
/// The first element in <paramref name="source" /> that passes the test in <paramref name="predicate" />.
507507
/// </returns>
508-
public static Task<TSource> FirstAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))
508+
public static Task<TSource> FirstAsync<TSource>(this IMongoQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))
509509
{
510510
return ((IMongoQueryProvider)source.Provider).ExecuteAsync<TSource>(
511511
Expression.Call(
@@ -524,7 +524,7 @@ public static IMongoQueryable<TSource> Distinct<TSource>(this IMongoQueryable<TS
524524
/// <returns>
525525
/// default(<typeparamref name="TSource" />) if <paramref name="source" /> is empty; otherwise, the first element in <paramref name="source" />.
526526
/// </returns>
527-
public static Task<TSource> FirstOrDefaultAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = default(CancellationToken))
527+
public static Task<TSource> FirstOrDefaultAsync<TSource>(this IMongoQueryable<TSource> source, CancellationToken cancellationToken = default(CancellationToken))
528528
{
529529
return ((IMongoQueryProvider)source.Provider).ExecuteAsync<TSource>(
530530
Expression.Call(
@@ -543,7 +543,7 @@ public static IMongoQueryable<TSource> Distinct<TSource>(this IMongoQueryable<TS
543543
/// <returns>
544544
/// default(<typeparamref name="TSource" />) if <paramref name="source" /> is empty or if no element passes the test specified by <paramref name="predicate" />; otherwise, the first element in <paramref name="source" /> that passes the test specified by <paramref name="predicate" />.
545545
/// </returns>
546-
public static Task<TSource> FirstOrDefaultAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))
546+
public static Task<TSource> FirstOrDefaultAsync<TSource>(this IMongoQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))
547547
{
548548
return ((IMongoQueryProvider)source.Provider).ExecuteAsync<TSource>(
549549
Expression.Call(
@@ -837,7 +837,7 @@ public static IOrderedMongoQueryable<TSource> OrderByDescending<TSource, TKey>(t
837837
/// <returns>
838838
/// A sample of the elements in the <paramref name="source"/>.
839839
/// </returns>
840-
public static IMongoQueryable<TSource> Sample<TSource>(this IQueryable<TSource> source, long count)
840+
public static IMongoQueryable<TSource> Sample<TSource>(this IMongoQueryable<TSource> source, long count)
841841
{
842842
return (IMongoQueryable<TSource>)source.Provider.CreateQuery<TSource>(
843843
Expression.Call(
@@ -907,7 +907,7 @@ public static IMongoQueryable<TResult> SelectMany<TSource, TCollection, TResult>
907907
/// <returns>
908908
/// The single element of the input sequence.
909909
/// </returns>
910-
public static Task<TSource> SingleAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = default(CancellationToken))
910+
public static Task<TSource> SingleAsync<TSource>(this IMongoQueryable<TSource> source, CancellationToken cancellationToken = default(CancellationToken))
911911
{
912912
return ((IMongoQueryProvider)source.Provider).ExecuteAsync<TSource>(
913913
Expression.Call(
@@ -926,7 +926,7 @@ public static IMongoQueryable<TResult> SelectMany<TSource, TCollection, TResult>
926926
/// <returns>
927927
/// The single element of the input sequence that satisfies the condition in <paramref name="predicate" />.
928928
/// </returns>
929-
public static Task<TSource> SingleAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))
929+
public static Task<TSource> SingleAsync<TSource>(this IMongoQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))
930930
{
931931
return ((IMongoQueryProvider)source.Provider).ExecuteAsync<TSource>(
932932
Expression.Call(
@@ -945,7 +945,7 @@ public static IMongoQueryable<TResult> SelectMany<TSource, TCollection, TResult>
945945
/// <returns>
946946
/// The single element of the input sequence, or default(<typeparamref name="TSource" />) if the sequence contains no elements.
947947
/// </returns>
948-
public static Task<TSource> SingleOrDefaultAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = default(CancellationToken))
948+
public static Task<TSource> SingleOrDefaultAsync<TSource>(this IMongoQueryable<TSource> source, CancellationToken cancellationToken = default(CancellationToken))
949949
{
950950
return ((IMongoQueryProvider)source.Provider).ExecuteAsync<TSource>(
951951
Expression.Call(
@@ -964,7 +964,7 @@ public static IMongoQueryable<TResult> SelectMany<TSource, TCollection, TResult>
964964
/// <returns>
965965
/// The single element of the input sequence that satisfies the condition in <paramref name="predicate" />, or default(<typeparamref name="TSource" />) if no such element is found.
966966
/// </returns>
967-
public static Task<TSource> SingleOrDefaultAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))
967+
public static Task<TSource> SingleOrDefaultAsync<TSource>(this IMongoQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))
968968
{
969969
return ((IMongoQueryProvider)source.Provider).ExecuteAsync<TSource>(
970970
Expression.Call(

0 commit comments

Comments
 (0)