In my database I have a many to many relationship with an association table
between, which consist of three classes (entities/tables) in my
ActiveRecord. I don't know why ICriterion sometimes can do deep queries (aka
within another class property) on one property and not the other property? I
get a "could not resolve property" server error. Thus, I decided
to investigate and dissect the problem:

*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> 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)
)); }


*Conclusion:*
I don't understand why ICriterion can deep query "Group.groupId"
propertyand not the "User.userIsDeleted"
property in my association table/class, it doesn't make sense? Please
explain? Bug?

For your information, I found someone else was having the same problem with
a workaround:
http://kyle.baley.org/ActiveRecordQueriesOrQuotHowToQueryDeepquot.aspx
*Specs: * ASPNET 3.5 SP1 MVC 1.0 MySQL 5.0.24a MySQL Connector/Net 6.1.1
NHibernate 2.1.0GA Castle ActiveRecord 2.0
Thank you for your help,
William Chang

--~--~---------~--~----~------------~-------~--~----~
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