This behavior is really misleading when no exception is thrown but the entities are loaded that weren't asked for.
In my case, the three entities I have EntityKeys for (one key per entity in this case) happened to use a single int key so the query could be built (here's what the keys contained):
EntityKeys[0].EntityType = User; EntityKeys[0].Values[0] = 1;
EntityKeys[1].EntityType = Status; EntityKeys[1].Values[0] = 3;
EntityKeys[2].EntityType = Group; EntityKeys[2].Values[0] = 4;
The query built was basically:
var query = em.User.Where (x => (((x.UserID == 1) OrElse (x.UserID == 3)) OrElse (x.UserID ==4)));
when it should have created three queries:
var query1 = em.User.Where (x => x.UserID == 1);
var query2 = em.Status.Where (x => x.StatusID ==3);
var query3 = em.Group.Where (x => x.GroupID ==4);
I assume there would be an exception thrown if I passed multiple entity keys for different entities with different structures or different number of keys. Either DevForce should throw an error if it gets mixed EntityTypes or it should only build the where clause based on keys matching the first entity type OR (and this would be my choice) it should do what I had to do:
I'm splitting up the EntityKeys into type-specific arrays of EntityKeys in a CoRoutine Parallel Async task and then building and executing the query for each specific type for all matching keys of that type.
I assume this is also an issue if you use an EntityKeyList.ToQuery method. Haven't tried that but it also looks like it expects a single entity type.