/// <summary>
        /// Parameterise all the constants so that the query can be cached by ORM
        /// </summary>
        /// <param name="dbObj"></param>
        /// <param name="ignoreEnumerable">Set to true if does not want to parameterise array.
        /// This is required if ORM does not support passing array as parameter.</param>
        /// <returns></returns>
        public static IDbConstant[] Parameterise(this IDbObject dbObj, bool ignoreEnumerable = false)
        {
            var constants = dbObj.GetDbObjects <IDbConstant>().Where(c => c.Val != null && c.AsParam).ToArray();

            if (ignoreEnumerable)
            {
                constants = constants.Where(c => !c.ValType.DotNetType.IsEnumerable()).ToArray();
            }

            var dict = new Dictionary <object, List <IDbConstant> >();

            foreach (var c in constants)
            {
                if (dict.ContainsKey(c.Val))
                {
                    dict[c.Val].Add(c);
                    continue;
                }

                dict[c.Val] = new List <IDbConstant>()
                {
                    c
                };
            }

            var parameters = dict.Values.ToArray();

            for (var i = 0; i < parameters.Length; i++)
            {
                foreach (var c in parameters[i])
                {
                    c.ParamName = $"@param{i}";
                }
            }

            return(parameters.Select(p => p.First()).ToArray());
        }