问题
I've got an extension for all entities:
public static class EntityBaseExtensions
{
public static T Clone<T>(this T item)
where T : EntityBase
{
return item.EntityClone<T>();
}
}
and
public virtual T EntityClone<T>() where T : EntityBase
{
return this.MemberwiseClone() as T;
}
but when i call it like:
var details = user.Details.Clone();
i get
Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true.
any ideas?
回答1:
the solution is kinda weird:
public static T Clone<T>(this T item)
where T : SimpleEntityBase
{
return (T)item.EntityClone();
}
and
public virtual object EntityClone()
{
return this.MemberwiseClone();
}
来源:https://stackoverflow.com/questions/19117874/late-bound-operations-cannot-be-performed-on-types-or-methods-for-which-contains