Given this method:
internal static IEnumerable<Entity> GetByParentImpl<Entity, TKey>(this ICanGetByParent<Entity, TKey> self, TKey parentId, string fieldName)
where Entity : class
{
RepositoryBase<Entity> rb = (RepositoryBase<Entity>)self;
rb.unitOfWork.Begin();
var entities = rb.unitOfWork.Session.QueryOver<Entity>()
.Where(e => EqualityComparer<TKey>.Default.Equals(GetId<Entity, TKey>(e, fieldName), parentId))
.List();
return entities;
}
And this helper:
private static TKey GetId<Entity, TKey>(object obj, string fieldName) where Entity : class
{
TKey id = default(TKey);
switch(id.GetType().Name) {
case "Int32":
break;
case "Guid":
id = (TKey)TypeDescriptor.GetConverter(typeof(TKey)).ConvertFromInvariantString((string)typeof(Entity).GetField(fieldName).GetValue(obj));
break;
}
return id;
}
I'm getting this exception on my linq statement:
Unrecognised method call: System.Collections.Generic.EqualityComparer`1[[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]:Boolean Equals(System.Guid, System.Guid)
What does this mean? I'm not even sure how to debug this correctly. I could have sworn that the code above was working...