I'am using wrapper to get some data from table User

IQueryable<StarGuestWrapper> WhereQuery =
session.Linq<User>().Where(u => u.HomeClub.Id == clubId &&
u.IsActive).Select(
                    u =>
                    new StarGuestWrapper()
                        {
                            FullName = u.Name + " " + u.LastName,
                            LoginTime = u.SomeDateTime,
                            MonthsAsMember = u.SomeIntergerValue,
                            StarRating = u.SomeOtherInteregValue,
                            UserPicture = u.Photo.PhotoData,
                            InstructorFullName = u.SomeInstructorName,
                            TalkInteractionDuringSession =
u.SomeBoolValue,
                            GoalInteractionDuringSession =
u.SomeOtherBoolValue
                        });

I use this without a problem as a IQueryable so I can do useful things
before actually running the query. Like :

WhereQuery.Skip(startRowIndex).Take(maximumRows).ToList();

and so on.

The problem occurs using 'where' statement on query. For example:

WhereQuery.Where(s => s.StarRating == 1)

will throw an exception in runtime that 'StarRating' doesn't exist in
User table - of course it doesn't it's a wrappers property. It will
work if I materialize query by

WhereQuery.AsEnumerable().Where(s => s.StarRating == 1)

but then it loses all the sens of using IQueryable and I don't want to
do this.

What is strange and interesting that not all properties from wrapper
throw error, all the bool values can be used in where statement.
Example :

WhereQuery.Where(s => s.TalkInteractionDuringSession)

It works in EntityFramework , why do I get this error in NHibernate
and how to get it working the way I want it to ?

-- 
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 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to