Skip to content

Commit 069dac1

Browse files
author
rstam
committed
Corrected a bunch of InvalidOperationExceptions to NotSupportedExceptions in the LINQ implementation because InvalidOperationException implies the operation could be valid in some other state.
1 parent b0ea8a7 commit 069dac1

File tree

2 files changed

+67
-67
lines changed

2 files changed

+67
-67
lines changed

Driver/Linq/Translators/SelectQuery.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public void Translate(Expression expression)
262262
break;
263263
default:
264264
var message = string.Format("The {0} query operator is not supported.", methodName);
265-
throw new InvalidOperationException(message);
265+
throw new NotSupportedException(message);
266266
}
267267
}
268268

@@ -821,7 +821,7 @@ private void CombinePredicateWithWhereClause(MethodCallExpression methodCallExpr
821821
if (_projection != null)
822822
{
823823
var message = string.Format("{0} with predicate after a projection is not supported.", methodCallExpression.Method.Name);
824-
throw new InvalidOperationException(message);
824+
throw new NotSupportedException(message);
825825
}
826826

827827
if (_where == null)
@@ -1012,7 +1012,7 @@ private void SetElementSelector(MethodCallExpression methodCallExpression, Func<
10121012
if (_elementSelector != null)
10131013
{
10141014
var message = string.Format("{0} cannot be combined with any other element selector.", methodCallExpression.Method.Name);
1015-
throw new InvalidOperationException(message);
1015+
throw new NotSupportedException(message);
10161016
}
10171017
_elementSelector = elementSelector;
10181018
}
@@ -1100,7 +1100,7 @@ private void TranslateDistinct(MethodCallExpression methodCallExpression)
11001100
if (arguments.Length != 1)
11011101
{
11021102
var message = "The version of the Distinct query operator with an equality comparer is not supported.";
1103-
throw new InvalidOperationException(message);
1103+
throw new NotSupportedException(message);
11041104
}
11051105

11061106
_distinct = true;
@@ -1285,7 +1285,7 @@ private void TranslateOrderBy(MethodCallExpression methodCallExpression)
12851285

12861286
if (_orderBy != null)
12871287
{
1288-
throw new InvalidOperationException("Only one OrderBy or OrderByDescending clause is allowed (use ThenBy or ThenByDescending for multiple order by clauses).");
1288+
throw new NotSupportedException("Only one OrderBy or OrderByDescending clause is allowed (use ThenBy or ThenByDescending for multiple order by clauses).");
12891289
}
12901290

12911291
var key = (LambdaExpression)StripQuote(methodCallExpression.Arguments[1]);
@@ -1307,7 +1307,7 @@ private void TranslateSelect(MethodCallExpression methodCallExpression)
13071307
if (lambdaExpression.Parameters.Count == 2)
13081308
{
13091309
var message = "The indexed version of the Select query operator is not supported.";
1310-
throw new InvalidOperationException(message);
1310+
throw new NotSupportedException(message);
13111311
}
13121312
if (lambdaExpression.Parameters.Count != 1)
13131313
{
@@ -1350,7 +1350,7 @@ private void TranslateThenBy(MethodCallExpression methodCallExpression)
13501350

13511351
if (_orderBy == null)
13521352
{
1353-
throw new InvalidOperationException("ThenBy or ThenByDescending can only be used after OrderBy or OrderByDescending.");
1353+
throw new NotSupportedException("ThenBy or ThenByDescending can only be used after OrderBy or OrderByDescending.");
13541354
}
13551355

13561356
var key = (LambdaExpression)StripQuote(methodCallExpression.Arguments[1]);
@@ -1371,7 +1371,7 @@ private void TranslateWhere(MethodCallExpression methodCallExpression)
13711371
if (predicate.Parameters.Count == 2)
13721372
{
13731373
var message = "The indexed version of the Where query operator is not supported.";
1374-
throw new InvalidOperationException(message);
1374+
throw new NotSupportedException(message);
13751375
}
13761376

13771377
CombinePredicateWithWhereClause(methodCallExpression, predicate);

0 commit comments

Comments
 (0)