Hello,
I've been using a patched version of NHibernate in order to have access to Criteria.Count. I want to stop using a modified NHibernate and I am planning to replace the following method with an equivalent from standard  distribution.
How can I refactor the following snippet?
Regards,
Robert
Code:
        /// <summary>
        /// Gets the total number of objects from the storage according to the filter specified in the properties.
        /// </summary>
        /// <param name="type">type of object to be counted in storage</param>
        /// <param name="propertyNames">array of property names of the object to be counted</param>
        /// <param name="propertyValues">array of property values of the object to be counted</param>
        /// <returns>number of objects counted in storage according to filters</returns>
        public long GetObjectsCount(Type type, string[] propertyNames, object[] propertyValues)
        {
            if ((propertyNames != null) && (propertyValues != null) && (propertyNames.Length != propertyValues.Length))
                throw new ArgumentException("Number of property names must match exactly the number of property values");
            try
            {
                ICriteria crit = session.CreateCriteria(type);
                if (propertyNames != null && propertyValues != null)
                    for (int i = 0; i < propertyNames.Length; i++)
                        crit.Add(Expression.Eq(propertyNames[i], propertyValues[i]));
                return crit.Count;
            }
            catch (HibernateException ex)
            {
                if (ExceptionPolicy.HandleException(ex, "Data Access Policy"))
                    throw;
            }
            return 0;
        }