public TResult Process <TResult>(IDbQuery <TResult> query) { if (query == null) { throw new ArgumentNullException("query"); } var handlerType = typeof(IDbQueryHandler <,>).MakeGenericType(query.GetType(), typeof(TResult)); dynamic handler = _serviceProvider.GetService(handlerType); handler.InstitutionCode = InstitutionCode; return(handler.Handle((dynamic)query)); }