Esempio n. 1
0
        /// <summary>
        /// Remove an index, and optionally, destroy it.
        /// </summary>
        /// <param name="name">Name.</param>
        /// <param name="destroy">True if you wish to delete its data.</param>
        public async Task Remove(string name, bool destroy)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            KomodoIndex idx = null;

            lock (_IndicesLock)
            {
                if (_Indices.Exists(i => i.Name.Equals(name)))
                {
                    idx = _Indices.First(i => i.Name.Equals(name));
                    _Indices.Remove(idx);

                    DbExpression e = new DbExpression(
                        _ORM.GetColumnName <Index>(nameof(Index.GUID)),
                        DbOperators.Equals,
                        idx.GUID);

                    _ORM.DeleteMany <Index>(e);
                }
            }

            if (idx != null)
            {
                if (destroy)
                {
                    await idx.Destroy();
                }
                idx.Dispose();
            }
        }