Ich habe eine generische Methode, die die letzte Datensatz aus einer Tabelle zurückgeben soll:Aufruf generische Methode mit Expression durch Reflexion
public T FindLast<TKey>(Expression<Func<T,TKey>> specification = null)
{
return specification == null
? Set().LastOrDefault()
: Set().OrderBy(specification).LastOrDefault();
}
Ich brauche es durch
Reflexion nennenvar methodCreateReadRepositoryAttr = (entityMetadata.GetEntityAttributeType() != null) ?
typeof(IRepositoryFactory).GetMethod("CreateReadRepository").MakeGenericMethod(entityMetadata.GetEntityAttributeType()) : null;
var methodEntityGet3 = attributeReadRepository.GetType().GetMethod("FindLast", new Type[] { typeof(Expression<Func<ArticleAttribute,int>>) });
Aber im Debug methodEntityGet3
ist Null. Was habe ich falsch gemacht?
Sind es zu nennen Sie in der Lage, ohne Reflexion? –