Actually, same problem with what I thought was the correct way to go.
Here is the call. Me = UserEntity that has already been filled with id = 1
_groupList = me.GetMultiGroupCollectionViaGroupUser(True)
The table information is in my first post.
Here is the generated code (Self Servicing)
Public Overridable Function GetMultiGroupCollectionViaGroupUser(forceFetch As Boolean, entityFactoryToUse As IEntityFactory) As CollectionClasses.GroupCollection
If ( Not _alreadyFetchedGroupCollectionViaGroupUser Or forceFetch Or alwaysFetchGroupCollectionViaGroupUser) AndAlso Not MyBase.IsSerializing AndAlso Not MyBase.IsDeserializing AndAlso Not MyBase.InDesignMode Then
If MyBase.ParticipatesInTransaction Then
If Not groupCollectionViaGroupUser.ParticipatesInTransaction Then
MyBase.Transaction.Add(_groupCollectionViaGroupUser)
End If
End If
Dim relations As IRelationCollection = New RelationCollection()
Dim Filter As IPredicateExpression = New PredicateExpression()
relations.Add(UserEntity.Relations.GroupUserEntityUsingUserId, "__UserEntity", "GroupUser", JoinHint.None)
relations.Add(GroupUserEntity.Relations.GroupEntityUsingUserId, "GroupUser", String.Empty, JoinHint.None)
Filter.Add(New FieldCompareValuePredicate(EntityFieldFactory.Create(UserFieldIndex.UserId), ComparisonOperator.Equal, Me.UserId))
_groupCollectionViaGroupUser.SuppressClearInGetMulti = Not forceFetch
If Not entityFactoryToUse Is Nothing Then
_groupCollectionViaGroupUser.EntityFactoryToUse = entityFactoryToUse
End If
_groupCollectionViaGroupUser.GetMulti(Filter, relations)
_groupCollectionViaGroupUser.SuppressClearInGetMulti = False
_alreadyFetchedGroupCollectionViaGroupUser = True
End If
Return _groupCollectionViaGroupUser
End Function
To me, this looks like it should be both running a join and returning records from the group table based on UserID = 1 (Through the GroupUser table). For some reason, I am only getting one record back but should get two. Any thoughts?
Sean