I have these codes in a service class. The intention is to query
domain entities from the database but map them to a DTO object to be
returned to the client.
public void TestQuery()
{
var q = GetSession().Linq<User>().Select(x => Map(x));
// Simulate evaluation of the LINQ expression
var l = q.ToList();
}
private UserDto Map(User x)
{
return new UserDto()
{
Id = x.Id,
Username = x.Username,
FullName = x.FullName,
Email = x.Email
};
}
It fails with the following exception,
Load operation failed for query 'TestQuery'. Unable to cast object of
type 'NHibernate.Linq.Expressions.EntityExpression' to type
'NHibernate.Linq.Expressions.CollectionAccessExpression'.
Anybody can help me with any clue to make this work?
p.s; I posted a similar question but I thought I'd post a shorter one
to pinpoint the problem.
http://groups.google.com/group/nhusers/browse_thread/thread/b70b3ef800f26d4f
--
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.