Hi friends, I have a DTO object like this:
public class TreeViewDTO
{
public string Value { get; set; }
public string Text { get; set; }
public bool HasChildren { get; set; }
}
and my entity mapped with Nhibernate is:
public class Entity
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual Entity Parent { get; set; }
/* other properties */
}
I would like to know, how can I get a List of my DTOs and fill the
HasChildren property using a count method or a subquery to know if there
are childrens?
I have tried this, but does not work:
return Session.QueryOver<Entity>
.Select(entity => new TreeViewViewModel() {
Value =
entity.Id.ToString(),
Text = entity.Name,
HasChildren =
(Session.QueryOver<Entity>().Where(x => x.ParentId == entity.Id).RowCount()
> 0)})
.ToList();
I got an exception with this: NotSupportedException and the messages says:
x => (x.Parent.Id == [100001].Id)
How could I create a query to fill this property?
Thank you.
--
______________________________________
Felipe B Oriani
felipeoriani.com.br [email protected]
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.