add function to encode class Entity ToDictionary