This project is read-only.

GetHashCode method problem with inherited entities


I just tried the 0.5 version of the template. It's great.
I have found a bug in the generator code. It doesn’t care the parent entity's properties. GetHashCode method generates the hash code from the declaring type's properties. In inherited entities the identity property is found in the topmost base class. It skipped by the generator too.
The same problem causes the issue with the equality methods. There will be missing properties in inherited entities.
So, I modified the template and added the following method:
IEnumerable<EdmProperty> GetAllProperties(EntityType entityType, EdmType parentType = null)
IEnumerable<EdmProperty> result = new EdmProperty[0];
var propsType = parentType == null ? entityType : parentType;

if (propsType.BaseType != null)
   result = GetAllProperties(entityType, propsType.BaseType);

result = result.Union(entityType.Properties.Where(p => p.DeclaringType == propsType));
return result;
Also replaced the foreach methods at the following line numbers:
253, 316, 332:
original: foreach(EdmProperty edmProperty in entity.Properties.Where(p => p.DeclaringType == entity))
replaced: foreach(EdmProperty edmProperty in GetAllProperties(entity))

file attachments