[Prev] Thread [Next]  |  [Prev] Date [Next]

[nhusers] Re: Aliased projection used in restriction Greg Wed Feb 08 08:00:27 2012

I found a solution but it is not nice. If there is a nicer solution do
let me know please.

     private IProjection GetProjectionByAlias(string alias)
            var projections = ((ProjectionList)

            for (int i = 0; i < projections.Length; i++)
                IProjection projection = projections[i];
                if (projection.Aliases.Length > 0 &&
projection.Aliases[0] == alias)
                    return projection;
            return null;

       IProjection projection = GetProjectionByAlias(alias);
       var restriction =  Restrictions.Eq(projection, value);

On Feb 6, 10:26 pm, Greg <[EMAIL PROTECTED]> wrote:
> Fabio Maulo quote:
> "An alias may optionally be assigned to a projection, so that the
> projected value may be referred to in restrictions or orderings."
> That's from here:http://knol.google.com/k/nhibernate-chapter-13-
> criteria-queries
> The article goes on showing how to use the alias for ordering, but not
> how to use it with restrictions.
> How can one use projection alias in restrictions?

You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at