コード例 #1
0
        /// <summary>
        /// get one data by filter
        /// 得到指定条件的一个数据
        /// </summary>
        /// <param name="ColumnName"></param>
        /// <returns></returns>
        public Object First(String ColumnName)
        {
            //数据库连接
            if (_connectionConfig.IsAutoCloseConnection == false)
            {
                if (_database.CheckStatus() == false)
                {
                    throw new Exception("databse connect not open");
                }
            }
            if (_connectionConfig.IsAutoCloseConnection == true)
            {
                _database.Open();
            }

            Object result;

            if (filterDefinition != null)
            {
                result = _database.GetSpeciaRecordValue(_databasename, _TableName, filterDefinition, ColumnName);
            }
            else
            {
                result = _database.GetSpeciaRecordValue(_databasename, _TableName, new BsonDocument(), ColumnName);
            }

            if (_connectionConfig.IsAutoCloseConnection == true)
            {
                _database.Close();
            }

            return(result);
        }