I am using MongoDB and I am attempting to save and it just does not return??
this is my controller:
public ActionResult doSomething(FormCollection collection)
{
if (collection == null || collection.Count == 0)
return View(Tenant);
var acct = new Account();
var whitelist = new String[]{"Name"};
TryUpdateModel(acct, whitelist, collection.ToValueProvider());
Tenant.Name = acct.Name;
Tenant.Save();
return View(Tenant);
}
and this is the Save method:
public override void Save(){
var acct = Application.Session.GetCollection<Account>();
acct.Save(this);
}
when it hits the line acct.Save(), it never returns. Any clue why this might happen?
The problem was that I was trying to use DateTime to store data as a MongoObject but MongoDB only has the following data types:
Integer (32-bit signed value) Long (64-bit signed value) Double (64-bit IEEE754 fp value) String
Unless you are using safe mode, this does not return (well, returns a null), see:
http://api.mongodb.org/csharp/1.4/html/2cdf9e5b-d850-994f-c6ba-54ded02c7589.htm
This is generally how MongoDB works, i.e. using a "fire and forget" methodology for writes/updates by default. If you want to have your application block or wait around for a result then the safe mode or write concern methods are there so you can do so.