public void Save(MetaCollection list)
        {
            if (list == null)
            {
                throw new ArgumentNullException(nameof(list));
            }

            _metaDataProvider.Save(list);
        }
        public static void SetCategoryId(this MetaCollection metaCollection, int categoryParentId, int categoryId, object value = null)
        {
            MetaEntity meta;

            if ((meta = metaCollection.FirstOrDefault(x => x.CategoryParentId == categoryParentId)) != null)
            {
                meta.CategoryId = categoryId;
                meta.MetaValue  = value;
            }
            else
            {
                metaCollection.Add(new MetaEntity()
                {
                    CategoryParentId = categoryParentId, CategoryId = categoryId, MetaValue = value
                });
            }
        }
        public void Save(IEntity entity, MetaCollection list, bool clearFirst = false)
        {
            // Because of properties where we store a pointer to the category and whether it is on or off, we can only have one instance of a category stored against an entity.
            // If we don't reselect that category again, it won't come through and therefore not updated (if null or empty remove meta relation)
            // In other meta relationships, we store the category all the time, and it's only the value that changes

            // update the metadata in the entity to have the right entityid and entitytype
            // if the caller has just executed an insert, the meta data may not have the entityid set against it so bruteforce update
            foreach (MetaEntity meta in list)
            {
                meta.MetaId = entity.EntityId;
            }

            if (clearFirst)
            {
                DeleteEntityMeta(entity);
            }

            Save(list);
        }
        public static int?GetCategoryId(this MetaCollection metaCollection, int categoryParentId)
        {
            MetaEntity meta;

            return((meta = metaCollection.FirstOrDefault(x => x.CategoryParentId == categoryParentId)) != null ? meta.CategoryId : (int?)null);
        }