It sounds like you shouldn't use generics at all. Generics are when your generic method doesn't need to know the type. The generic type parameter signals that this method can work with any particular type.
Perhaps for both cases you should have only two methods with special workarounds. This makes all casting and complexity go away.
But if you insist on a universal method, here's how to do it. First create the special case that I talked about.
public static C GetAllInfo(this IQueryable<A> objCust);
Then tell them:
public static C GetAllInfo<T>(this IQueryable<T> objCust) { if (typeof(T) == typeof(B)) { return GetAllInfo((IQueryable<B>)objCust); //call to specialized impl. } if (typeof(T) == typeof(A)) { return GetAllInfo((IQueryable<A>)objCust); //call to specialized impl. } //fail }
source share