How to Define Extension Method for ICollection<T> where T : IMyInterface without Specifying T in the Method Definition
问题 Background: I want to hook in business rules at the point that DTOs are being mapped to entities. I figured encapsulating the mapping into an extension method would be a good route. IEntityDto is the interface that all DTOs that can be directly mapped to entities implement. The single instance works fine: public static TEntity MapTo<TEntity>(this IEntityDto dto) { ... Run Business Rules that don't require db access ... return AutoMapper.Mapper.Map<TEntity>(dto); } I'd like to also extend