Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true

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?

like image 308
Roar Avatar asked Oct 15 '25 07:10

Roar


1 Answers

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();
}
like image 181
Roar Avatar answered Oct 19 '25 14:10

Roar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!