The problem is not with the user class, but with the query itself.
ICriterion cannot have paths that check properties unless they are aliased
in the criteria query. The example that works, does so only because you are
using the id, which actually is the foreign key in the entity itself.

To implement this behaviour, we had to inspect the criterions and fetch the
referenced types before applying the criterions. If you send me a patch, I
will look into it.

-Markus

2009/8/27 William Chang <[email protected]>

>
> I sent a private email containing the source code file attachments to
> Markus Zywitza.
>
> Let me know anybody wants to see it?
>
> Sincerely,
> William Chang
> http://www.williamchang.org
> http://www.babybluebox.com
>
> On Aug 27, 10:32 am, Markus Zywitza <[email protected]> wrote:
> > Can you send the mappings for GroupMember, Group and User?
> >
> > -Markus
> >
> > 2009/8/24 William Chang <[email protected]>
> >
> >
> >
> >
> >
> > > SOURCE CODE FORMATING CORRECTION (don't use gmail)
> >
> > > From my understanding, I thought doing this FIRST make sense, because
> > > ICriterion can take multiple criteria on properties. But, I get a
> > > server error, "could not resolve property: memberUser.userIsDeleted
> > > of: Testsoft.Data.Models.GroupMember":
> > >    /// <summary>Get group members.</summary>
> > >    public static IList<Models.GroupMember> GetGroupMembers(Guid
> > > groupId) {
> > >        return Models.GroupMember.FindAll(
> > >            Restrictions.And(
> > >                Restrictions.Eq("memberGroup.groupId", groupId),
> > >                Restrictions.Eq("memberUser.userIsDeleted", false)
> > >            )
> > >        );
> > >    }
> >
> > > This works, it is a deep query into another class called "Group"
> > > containing a property called "groupId".
> > >    /// <summary>Get group members.</summary>
> > >    /// <summary>Get group members.</summary>
> > >    public static IList<Models.GroupMember> GetGroupMembers(Guid
> > > groupId) {
> > >        return Models.GroupMember.FindAll(
> > >            Restrictions.Eq("memberGroup.groupId", groupId)
> > >        );
> > >    }
> >
> > > This doesn't work, same idea as above Group.groupId, but doing only
> > > User.userIsDeleted. I got a server error, "could not resolve property:
> > > memberUser.userIsDeleted of: Testsoft.Data.Models.GroupMember":
> > >    /// <summary>Get group members.</summary>
> > >    public static IList<Models.GroupMember> GetGroupMembers(Guid
> > > groupId) {
> > >        return Models.GroupMember.FindAll(
> > >            Restrictions.Eq("memberUser.userIsDeleted", false)
> > >        );
> > >    }
> >
> > > My workaround, I end up using "DetachedCriteria" to do a deep query
> > > with multiple criteria of properties from different classes (aka
> > > entities):
> > >    /// <summary>Get group members.</summary>
> > >    public static IList<Models.GroupMember> GetGroupMembers(Guid
> > > groupId) {
> > >        return Models.GroupMember.FindAll
> > > (DetachedCriteria.For<Models.GroupMember>().Add(
> > >            Restrictions.Eq("memberGroup.groupId", groupId)
> > >        ).CreateCriteria("memberUser").Add(
> > >            Restrictions.Eq("userIsDeleted", false)
> > >        ));
> > >    }
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to