Skip to content

Commit

Permalink
Review #639.
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-tkachev committed Apr 21, 2017
1 parent 854566f commit 4aae278
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Source/Linq/Builder/GroupByBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public Expression GetGrouping(GroupByContext context)
if (context._element.Lambda.Parameters.Count == 1 &&
context._element.Body == context._element.Lambda.Parameters[0])
{
var ex = new InvalidOperationException(
var ex = new LinqToDBException(
"You should explicitly specify selected fields for server-side GroupBy() call or add AsEnumerable() call before GroupBy() to perform client-side grouping.\n" +
"Set Configuration.Linq.GuardGrouping = false to disable this check."
);
Expand Down
15 changes: 11 additions & 4 deletions Tests/Linq/Linq/GroupByTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1841,28 +1841,35 @@ public void GroupByGuard(string context)
Assert.AreEqual(2, dictionary1.Count);
Assert.AreEqual(2, dictionary1.First().Value.Count);

Assert.Throws<InvalidOperationException>(() =>
var list =
(
from p in db.Person
group p by p.Gender into gr
select new { gr.Key, Count = gr.Count() }
)
.ToDictionary(_ => _.Key);

Assert.Throws<LinqToDBException>(() =>
{
// group on server
db.Person
.GroupBy(_ => _.Gender)
.ToDictionary(_ => _.Key, _ => _.ToList());
});

Assert.Throws<InvalidOperationException>(() =>
Assert.Throws<LinqToDBException>(() =>
{
db.Person
.GroupBy(_ => _)
.ToDictionary(_ => _.Key, _ => _.ToList());
});

Assert.Throws<InvalidOperationException>(() =>
Assert.Throws<LinqToDBException>(() =>
{
db.Person
.GroupBy(_ => _)
.ToList();
});

}
}
}
Expand Down

0 comments on commit 4aae278

Please sign in to comment.