Version: LLBLGen Pro 2.5
Build Number: Dec 5th 2007
Runtime Library Version: 2.5.08.0122
Template Group: SelfServicing
DotNet: 2.0
Database Type: SQL Server 2000
Hi I'm having a bit of trouble designing the necessary llblgen code to perform the following SQL request:
SELECT u.*
FROM User u
JOIN UserGroupMember m ON m.UserId = a.UserId
JOIN Group g ON g.GroupId = m.GroupId
WHERE u.IsDeleted = 0
AND g.IsDeleted = 0
ORDER BY m.Order
So you see I am requesting a collection of Users, filtered by the deleted properties of itself and the related table. I am also requesting the order to be according to the member table Order column.
So far I have come up with the following LLBLGen code:
UserCollection users = new UserCollection();
IPredicateExpression filter = new PredicateExpression();
IRelationCollection relations = new RelationCollection();
filter.Add(UserFields.Deleted == 0);
filter.Add(GroupFields.Deleted == 0);
// link in to the query the member table, and the group table
relations.Add(UserEntity.Relations.UserGroupMemberEntityUsingUserId);
relations.Add(UserGroupMemberEntity.Relations.GroupEntityUsingGroupId);
sort.Add(new SortClause(UserGroupMember.Order, SortOperator.Ascending));
users.GetMulti(filter, long.MaxValue, sort, relations);
This seems to work, but I wonder if you can just take a look to confirm if this is the best way to do it?
Many thanks for any comments