enhance where command array manipulation

Array of entities is replaced by array of entities' primary key values
for IN clause in where command.