A common pattern in this case is to have a non-generic base type of the generic base type. If your method doesn't involve the type parameter, then you're done. If it does, you could add a non-generic method that does a typecast, similar to Object.Equals:
public abstract class ReallyBaseType
{
public abstract void SomeMethod();
public abstract void SomeMethodWithParameter(object o);
}
public abstract class BaseType<TEntity> : ReallyBaseType
where TEntity : BaseType<TEntity>
{
public override void SomeMethodWithParameter(object o)
{
SomeMethodWithParameter((TEntity)o);
}
public abstract void SomeMethodWithParameter(TEntity entity);
}
public class AnyType : BaseType<AnyType>
{
public override void SomeMethod() { }
public override void SomeMethodWithParameter(AnyType entity) { }
}
Then, you can just check the actual type of data:
public void Method<T>(T data)
{
if (data is ReallyBaseType)
{
((ReallyBaseType)(object)data).SomeMethod();
}
}
EDIT: I think you're stuck using reflection, then. If you want to be able to write code against the concrete type, you could create a generic method and invoke it using reflection:
public class TestClass
{
private static MethodInfo innerMethodDefinition =
typeof(TestClass).GetMethod("InnerMethod");
public void Method(object data)
{
var t = data.GetType();
while (t != null &&
!(t.IsGenericType &&
t.GetGenericTypeDefinition() == typeof(BaseType<>)))
{
t = t.BaseType;
}
if (t != null &&
t.GetGenericArguments()[0].IsAssignableFrom(data.GetType()))
{
innerMethodDefinition.MakeGenericMethod(
t.GetGenericArguments()[0]).Invoke(this, new object[] { data });
}
}
public void InnerMethod<TEntity>(TEntity data)
where TEntity : BaseType<TEntity>
{
// Here you have the object with the correct type
}
}