Changed order of encodeValue to check if it is an emedded EntityKind so isDouble would not fail