Exemplo n.º 1
0
        /// <summary>
        /// delete data by key value
        /// 删除指定条件数据
        /// </summary>
        /// <param name="KeyColumnName"></param>
        /// <param name="KeyValue"></param>
        /// <returns></returns>
        public MongoDeleteData Where(string KeyColumnName, CommandComparison comparison,
                                     object KeyValue)
        {
            filterDefinition = MongoDBOP.GetFilterOP(KeyColumnName, KeyValue, comparison);

            return(this);
        }
Exemplo n.º 2
0
        /// <summary>
        /// update many new data
        /// 更新多个数据
        /// </summary>
        /// <param name="KeyColumnName"></param>
        /// <param name="comparison"></param>
        /// <param name="KeyValue"></param>
        /// <param name="relation"></param>
        /// <returns></returns>
        public MongoUpdateData Where(String[] KeyColumnName,
                                     CommandComparison[] comparison, Object[] KeyValue, WhereRelation[] relation)
        {
            filterDefinition = MongoDBOP.GetWhere(KeyColumnName, KeyValue, comparison, relation);

            return(this);
        }
Exemplo n.º 3
0
        /// <summary>
        /// get data by filter
        /// 得到指定条件的表中所有数据
        /// </summary>
        /// <param name="ColumnName">筛选字段名 Filed</param>
        /// <param name="Value">筛选值 Filter value</param>
        /// <param name="Comparison">筛选条件 Filter where</param>
        /// <returns></returns>
        public MongoGetData Where(String ColumnName, Object Value,
                                  CommandComparison Comparison)
        {
            filterDefinition = MongoDBOP.GetFilterOP(ColumnName, Value, Comparison);

            return(this);
        }
Exemplo n.º 4
0
        /// <summary>
        /// update many new data
        /// 更新多个数据
        /// </summary>
        /// <param name="KeyColumnName"></param>
        /// <param name="KeyValue"></param>
        /// <returns></returns>
        public MongoUpdateData Where(String[] KeyColumnName,
                                     Object[] KeyValue)
        {
            filterDefinition = MongoDBOP.GetWhere(KeyColumnName, KeyValue);

            return(this);
        }
Exemplo n.º 5
0
        /// <summary>
        /// delete data by many key value
        /// 删除多个指定条件数据
        /// </summary>
        /// <param name="KeyColumnName"></param>
        /// <param name="KeyValue"></param>
        /// <returns></returns>
        public MongoDeleteData Where(string[] KeyColumnName, object[] KeyValue)
        {
            if (KeyColumnName.Length != KeyValue.Length)
            {
                throw new Exception("Column number not Equals Value number");
            }

            filterDefinition = MongoDBOP.GetWhere(KeyColumnName, KeyValue);

            return(this);
        }
Exemplo n.º 6
0
        /// <summary>
        /// get data by filter
        /// 得到指定条件的表中所有数据
        /// </summary>
        /// <param name="ColumnName">筛选字段名 Filed</param>
        /// <param name="Value">筛选值 Filter value</param>
        /// <returns></returns>
        public MongoGetData Where(String[] ColumnName, Object[] Value)
        {
            if (ColumnName.Length != Value.Length)
            {
                throw new Exception("Column number not Equals Value number");
            }

            filterDefinition = MongoDBOP.GetWhere(ColumnName, Value);

            return(this);
        }
Exemplo n.º 7
0
        /// <summary>
        /// delete data by many key value
        /// 删除多个指定条件数据
        /// </summary>
        /// <param name="KeyColumnName"></param>
        /// <param name="KeyValue"></param>
        /// <returns></returns>
        public MongoDeleteData Where(string[] KeyColumnName, CommandComparison[] comparison,
                                     object[] KeyValue, WhereRelation[] relation)
        {
            if (KeyColumnName.Length != KeyValue.Length)
            {
                throw new Exception("Column number not Equals Value number");
            }

            filterDefinition = MongoDBOP.GetWhere(KeyColumnName, KeyValue, comparison, relation);

            return(this);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 多种查询条件组合
        /// </summary>
        /// <param name="ColumnName"></param>
        /// <param name="Value"></param>
        /// <returns></returns>
        public static FilterDefinition <BsonDocument> GetWhere(String[] ColumnName, Object[] Value)
        {
            FilterDefinition <BsonDocument> definition = new BsonDocument();

            for (int i = 0; i < ColumnName.Length; i++)
            {
                FilterDefinition <BsonDocument> def = MongoDBOP.GetFilterOP(ColumnName[i], Value[i], CommandComparison.Equals);

                definition = definition & def;
            }

            return(definition);
        }
Exemplo n.º 9
0
        /// <summary>
        /// get data by filter
        /// 得到指定条件的表中所有数据
        /// </summary>
        /// <param name="ColumnName">筛选字段名 Filed</param>
        /// <param name="Comparison">筛选条件 Filter where</param>
        /// <param name="Value">筛选值 Filter value</param>
        /// <param name="relation">筛选关系 relation</param>
        /// <returns></returns>
        public MongoGetData Where(String[] ColumnName, CommandComparison[] Comparison,
                                  Object[] Value, WhereRelation[] relation)
        {
            if (ColumnName.Length != Value.Length && ColumnName.Length != Comparison.Length &&
                ColumnName.Length != relation.Length)
            {
                throw new Exception("Column number not Equals Value number");
            }


            filterDefinition = MongoDBOP.GetWhere(ColumnName, Value, Comparison, relation);

            return(this);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 多种查询条件组合
        /// </summary>
        /// <param name="ColumnName"></param>
        /// <param name="Value"></param>
        /// <param name="comparison"></param>
        /// <param name="relation"></param>
        /// <returns></returns>
        public static FilterDefinition <BsonDocument> GetWhere(String[] ColumnName, Object[] Value,
                                                               CommandComparison[] comparison, WhereRelation[] relation)
        {
            FilterDefinition <BsonDocument> definition = new BsonDocument();

            for (int i = 0; i < ColumnName.Length; i++)
            {
                FilterDefinition <BsonDocument> def = MongoDBOP.GetFilterOP(ColumnName[i], Value[i], comparison[i]);


                if (relation[i] != WhereRelation.Or)
                {
                    definition = definition & def;
                }
                else
                {
                    definition = definition | def;
                }
            }

            return(definition);
        }
Exemplo n.º 11
0
        /// <summary>
        /// update new data
        /// 更新数据
        /// </summary>
        /// <param name="KeyColumnName"></param>
        /// <param name="KeyValue"></param>
        /// <returns></returns>
        public MongoUpdateData Where(String KeyColumnName, Object KeyValue)
        {
            filterDefinition = MongoDBOP.GetFilterOP(KeyColumnName, KeyValue, CommandComparison.Equals);

            return(this);
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
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;
        }
Exemplo n.º 14
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;
        }