我有一个具有集合状态的 mongo 服务器。每当添加新状态时,它都会保存在我的服务器中。但是当我尝试在前端编辑集合时,它会在我的服务器中保存为另一个具有不同 ID 的新集合。如何克服这一点。
public static void CreateData(string pass ,string pass1)
{
string StateCode = pass;
string stateName = pass1;
insertState(StateCode, stateName);
}
private static void insertState(string StateCode, string stateName)
{
MongoServer server = MongoServer.Create(ConnectionString);
MongoDatabase myCompany = server.GetDatabase("BackOffice");
MongoCollection<BsonDocument> tblStates = myCompany.GetCollection<BsonDocument>("tblStates");
BsonDocument deptartment = new BsonDocument {
{ "State_strCode", StateCode },
{ "State_strName", stateName },
{"States_strIsActive","Y"},
{"State_strFedExStateCode",""},
{"State_dtmTimeStamp",DateTime.Now}
};
tblStates.Insert(deptartment);
}