示例#1
0
        /** \fn bool IsCollectionExist(string colName)
         *  \brief Verify the existence of collection in current colleciont space
         *  \param colName The collection name
         *  \return True if collection existed or False if not existed
         *  \exception SequoiaDB.BaseException
         *  \exception System.Exception
         */
        public bool IsCollectionExist(string colName)
        {
            string command = SequoiadbConstants.ADMIN_PROMPT + SequoiadbConstants.TEST_CMD + " "
                             + SequoiadbConstants.COLLECTION;
            BsonDocument condition = new BsonDocument();
            BsonDocument dummyObj  = new BsonDocument();
            string       fullName  = this.Name + "." + colName;

            condition.Add(SequoiadbConstants.FIELD_NAME, fullName);
            SDBMessage rtn   = AdminCommand(command, condition, dummyObj, dummyObj, dummyObj);
            int        flags = rtn.Flags;

            if (flags == 0)
            {
                sdb.UpsertCache(fullName);
                return(true);
            }
            else if (flags == (int)Errors.errors.SDB_DMS_NOTEXIST)
            {
                sdb.RemoveCache(fullName);
                return(false);
            }
            else
            {
                throw new BaseException(flags);
            }
        }