Web.Config file :
<add key="MongoDbConnectionString" value="mongodb://localhost:27017" />
<add key="MongoDb" value="local" />
DataAccessMongo.Cs
---------------------------
try
{
connectionString = ConfigurationManager.AppSettings[mongoConnKey];
mongoDatabase = ConfigurationManager.AppSettings[mongodb];
var client = new MongoClient(connectionString);
var database = client.GetDatabase(mongoDatabase);
var Collec = database.GetCollection<BsonDocument>("TestCollection");
var documnt = new BsonDocument
{
{"Transactionid","1"}
};
BsonDocument array = new BsonDocument {
{"Please select your account type",accounttype },
{"What type of promition are you sending",promtypr},
{"What type would you like to target",grptype}
};
documnt.Add("GroupSelection", array);
var filterDefinition = Builders<BsonDocument>.Filter.Eq("StoreId", "1");
var updateDefinition = Builders<BsonDocument>.Update.Set("GroupSelection", array);
Collec.UpdateMany(filterDefinition, updateDefinition);
return true;
}
catch(Exception ex)
{
throw ex;
}
<add key="MongoDbConnectionString" value="mongodb://localhost:27017" />
<add key="MongoDb" value="local" />
DataAccessMongo.Cs
---------------------------
try
{
connectionString = ConfigurationManager.AppSettings[mongoConnKey];
mongoDatabase = ConfigurationManager.AppSettings[mongodb];
var client = new MongoClient(connectionString);
var database = client.GetDatabase(mongoDatabase);
var Collec = database.GetCollection<BsonDocument>("TestCollection");
var documnt = new BsonDocument
{
{"Transactionid","1"}
};
BsonDocument array = new BsonDocument {
{"Please select your account type",accounttype },
{"What type of promition are you sending",promtypr},
{"What type would you like to target",grptype}
};
documnt.Add("GroupSelection", array);
var filterDefinition = Builders<BsonDocument>.Filter.Eq("StoreId", "1");
var updateDefinition = Builders<BsonDocument>.Update.Set("GroupSelection", array);
Collec.UpdateMany(filterDefinition, updateDefinition);
return true;
}
catch(Exception ex)
{
throw ex;
}
No comments:
Post a Comment