Thanks Frans, but I've been trying numerous combinations without success
The full logic I'm using is:
IEntityRelation relation = new EntityRelation(RelationType.OneToMany);
relation.AddEntityFieldPair(EntityFieldFactory.Create(PermissionFieldIndex.GroupUID), EntityFieldFactory.Create(FolderLinkFieldIndex.ParentFolderUID));
relation.StartEntityIsPkSide = true;
IRelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.PredicateExpression.Add(PredicateFactory.CompareRange(FolderLinkFieldIndex.ChildFolderUID, childFolderUIDs));
bucket.PredicateExpression.Add(PredicateFactory.CompareRange(PermissionFieldIndex.GroupUID, groupUIDs));
bucket.Relations.Add(relation);
EntityCollection folderLinkEntities = new EntityCollection(new FolderLinkEntityFactory());
adapter.FetchEntityCollection(folderLinkEntities, bucket);
Which generate the following SQL which contains a syntax error "Incorrect syntax near the keyword 'And'." (found at the start of the WHERE clause).
exec sp_executesql N'SELECT [Permission].[ResourceUID] AS [ResourceUID],[Permission].[GroupUID] AS [GroupUID],[Permission].[SkinAccountUID] AS [SkinAccountUID],[Permission].[CanCreate] AS [CanCreate],[Permission].[CanRead] AS [CanRead],[Permission].[CanUpdate] AS [CanUpdate],[Permission].[CanDelete] AS [CanDelete],[Permission].[CanChangePermissions] AS [CanChangePermissions],[Permission].[CanPurchase] AS [CanPurchase],[Permission].[CanShare] AS [CanShare],[Permission].[Protection] AS [Protection],[Permission].[OwnerUID] AS [OwnerUID],[Permission].[Timestamp] AS [Timestamp] FROM [Permission] WHERE ( And [Permission].[GroupUID] IN (@GroupUID1, @GroupUID2, @GroupUID3, @GroupUID4) And [Permission].[SkinAccountUID] = @SkinAccountUID5) ORDER BY [Permission].[ResourceUID] ASC', N'@GroupUID1 uniqueidentifier,@GroupUID2 uniqueidentifier,@GroupUID3 uniqueidentifier,@GroupUID4 uniqueidentifier,@SkinAccountUID5 uniqueidentifier', @GroupUID1 = '5D93106C-FA0A-4913-A59D-792A9D3A1C0D', @GroupUID2 = 'BA060CE1-3733-44ED-A550-F63B34C2F76B', @GroupUID3 = '94E31AA3-A0B7-46E4-A40A-F43C9266DB03', @GroupUID4 = 'FD872A62-CD27-49A7-9946-A9A361BFDFDB', @SkinAccountUID5 = 'AA5BCACF-1FDB-4FA8-BF3F-E3876B27A866'
UPDATE... and I just noticed... this is fetching the wrong table and putting in an ORDER BY????
UPDATE 2... I've also tried swapping the order of the fields in AddEntityFieldPair which makes no difference.
UPDATE 3... SORRY... I think the code above is actually working... My Bad
Thanks for your help... I took the wrong SQL from the Profiler!!!
Marcus