forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NH-3474 - Fix support of GroupBy with constant keys
* Remove the GROUP BY clause entirely if all keys are constant * Re-write the GROUP BY clause using only non-constant keys * Adjust the ExpressionKeyVisitor so that constants in GroupBy are not replaced with parameter * Fix ExpressionKeyVisitor handling of constant arrays to show initialization values
- Loading branch information
Showing
5 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using System.Text; | ||
using NHibernate.Util; | ||
using Remotion.Linq.Clauses.ResultOperators; | ||
|
||
namespace NHibernate.Linq | ||
{ | ||
internal static class GroupResultOperatorExtensions | ||
{ | ||
public static IEnumerable<Expression> ExtractKeyExpressions(this GroupResultOperator groupResult) | ||
{ | ||
if (groupResult.KeySelector is NewExpression) | ||
return (groupResult.KeySelector as NewExpression).Arguments; | ||
if (groupResult.KeySelector is NewArrayExpression) | ||
return (groupResult.KeySelector as NewArrayExpression).Expressions; | ||
return new [] { groupResult.KeySelector }; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters