Strange Behaviour When Using With() And Together

I have Item, Category and ItemCategory as models

Item may belong to many Categories

A Category may have Many Items

So in my CGridView if I search (_search form) for Category A, I could get 100 items but I would never get any item twice.

If I search for Category A and B, I might get any item N more than once.

It seems the paging function doesn’t work well when facing any kind of replication of data in the CGridView / DataProvider.

Any suggestions as to how to make it behave a bit better?

Is there a way to use mergeWith() or something else to control the data loading?