I have 3 tables, Groups, Users and Members. There are 2 entities, UserDto,
GroupDto. I am trying to fetch/eager load the members if a group. The
problem is that fetching is not working. What I am doing wrong?
MAPPING:
public class GroupDtoMap : DtoClassMap<GroupDto>
{
public GroupDtoMap()
{
Id(g => g.Id, "group_id");
HasManyToMany(g => g.Members) // Members is a List<UserDto>
.Table("members")
.ParentKeyColumn("group_id")
.ChildKeyColumn("user_id");
}
}
QUERY:
var groups = ((DtoRepository<GroupDto>)repository).Session
.CreateCriteria<GroupDto>("gr")
.Add(Expression.Eq("gr.IsActive", true))
.Add(Expression.IsNotNull("gr.Members.Id"))
.SetFetchMode("gr.Members", NHibernate.FetchMode.Eager)
.SetResultTransformer(new DistinctRootEntityResultTransformer())
.Future<GroupDto>();
TEST: here isfetched is false
var isFetched = NHibernateUtil.IsInitialized(groups.First().Members);
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/nhusers/-/pW91Ljl2ZtYJ.
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.