public int GetPaymentCount(Type paymentType) { var payments = _context.Set(paymentType) as IQueryable <dynamic>; return((payments ?? throw new InvalidOperationException()).Count()); }