/// <summary>
        /// Gets <see cref="IEntityFilterGroup"/> by it's key.
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <returns>
        /// The <see cref="IEntityFilterGroup"/>.
        /// </returns>
        /// <remarks>
        /// TODO this is pretty brittle since it assumes the collection will be intended to be used as the special filter group.
        /// However, it merely builds a filter group using whatever collection and it's children - so Service should definitely
        /// have this as an internal method until we can refactor
        /// </remarks>
        public IEntityFilterGroup GetEntityFilterGroup(Guid key)
        {
            var cacheKey = Cache.CacheKeys.GetEntityCacheKey <IEntityFilterGroup>(key);
            var cached   = (IEntityFilterGroup)RuntimeCache.GetCacheItem(cacheKey);

            if (cached != null)
            {
                return(cached);
            }

            var collection = Get(key);

            if (collection == null)
            {
                return(null);
            }
            var query = Querying.Query <IEntityCollection> .Builder.Where(x => x.ParentKey == key);

            var children = GetByQuery(query);

            var filterGroup = new EntityFilterGroup(collection);

            foreach (var child in children)
            {
                filterGroup.Filters.Add(child);
            }

            return((IEntityFilterGroup)RuntimeCache.GetCacheItem(cacheKey, () => filterGroup));
        }
        /// <summary>
        /// Gets <see cref="IEntityFilterGroup"/> by it's key.
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <returns>
        /// The <see cref="IEntityFilterGroup"/>.
        /// </returns>
        /// <remarks>
        /// TODO this is pretty brittle since it assumes the collection will be intended to be used as the special filter group.
        /// However, it merely builds a filter group using whatever collection and it's children - so Service should definitely
        /// have this as an internal method until we can refactor
        /// </remarks>
        public IEntityFilterGroup GetEntityFilterGroup(Guid key)
        {
            var collection = Get(key);

            if (collection == null)
            {
                return(null);
            }
            var query = Querying.Query <IEntityCollection> .Builder.Where(x => x.ParentKey == key);

            var children = GetByQuery(query);

            var filterGroup = new EntityFilterGroup(collection);

            foreach (var child in children)
            {
                filterGroup.Filters.Add(child);
            }

            return(filterGroup);
        }