why would Collection.IMongo.Save() not return?

Go To StackoverFlow.com

0

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?

2012-04-05 19:09
by caradrye


1

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

http://code.google.com/p/morphia/wiki/PropertyAnnotation

2012-06-14 16:20
by caradrye


1

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.

2012-04-06 09:59
by Adam Comerford
It's not that I am expecting a value, it's that when I call the method , the program "freezes" like it is stuck in an infinite loop - caradrye 2012-04-06 13:39
Ah, OK - I misunderstood that a little then, my C# knowledge is rudimentary to say the least, but without more info on the methods and view used (TryUpdateModel and the returned value) it would be hard to comment on the source of the issue - Adam Comerford 2012-04-10 15:39
I figure out the problem after all and it was because I was using TimeSpan for one of my variables in my .cs file and Mongo did not like tha - caradrye 2012-04-11 14:21
Cool - feel free to answer your own question with some details and I will happily vote it up : - Adam Comerford 2012-04-11 15:04
Ads