Пример #1
0
        /// <summary>
        /// insert new data
        /// 插入新数据
        /// </summary>
        public void ExecuteCommand()
        {
            //数据库连接
            if (_connectionConfig.IsAutoCloseConnection == false)
            {
                if (_database.CheckStatus() == false)
                {
                    throw new Exception("databse connect not open");
                }
            }
            if (_connectionConfig.IsAutoCloseConnection == true)
            {
                _database.Open();
            }
            _database.InsertData(_databasename, _TableName, MongoDB.Bson.Serialization.BsonSerializer.Deserialize <BsonDocument>(MongoDBOP.HashtableToJson(htData)));

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

            return;
        }
Пример #2
0
        /// <summary>
        /// insert new data
        /// 插入新数据
        /// </summary>
        public String ExecuteCommand(String KeyColumnName, String GUIDValue)
        {
            //数据库连接
            if (_connectionConfig.IsAutoCloseConnection == false)
            {
                if (_database.CheckStatus() == false)
                {
                    throw new Exception("databse connect not open");
                }
            }
            if (_connectionConfig.IsAutoCloseConnection == true)
            {
                _database.Open();
            }
            String s = _database.InsertData(_databasename, _TableName, MongoDB.Bson.Serialization.BsonSerializer.Deserialize <BsonDocument>(MongoDBOP.HashtableToJson(htData))
                                            , KeyColumnName, GUIDValue);

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

            return(s);
        }
Пример #3
0
        /// <summary>
        /// insert many new data
        /// 插入多个新数据
        /// </summary>
        /// <param name="ht"></param>
        public void ExecuteCommand(List <Hashtable> ht)
        {
            if (ht.Count == 0)
            {
                throw new Exception("Column number not Equals Value number");
            }

            BsonDocument[] document = new BsonDocument[ht.Count];
            for (int i = 0; i < ht.Count; i++)
            {
                document[i] = MongoDB.Bson.Serialization.BsonSerializer.Deserialize <BsonDocument>(MongoDBOP.HashtableToJson(ht[i]));
            }
            //数据库连接
            if (_connectionConfig.IsAutoCloseConnection == false)
            {
                if (_database.CheckStatus() == false)
                {
                    throw new Exception("databse connect not open");
                }
            }
            if (_connectionConfig.IsAutoCloseConnection == true)
            {
                _database.Open();
            }
            _database.InsertData(_databasename, _TableName, document);

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

            return;
        }