I have an Object
public class Object1{
public List<Object2> {get;set;}
}
public class Object2{
public Name{get;set;}
public Address{get;set;}
}
I have a feature where the user can update just one instance of Object2. So my code for saving Object2 looks like
[HttpPost]
public ActionResult SaveObject2(Object2 obj2)
{
if (obj2.Id == null){
//Add Logic
obj1.Obj2List.Add(obj2)
}
else{
// Update logic
}
}
But obj2.Id is never null.Id is of type ObjectId. How can i check for logic to see if need to insert or update ? I am using asp.net MVC 3 and Mongo DB using the official C# drivers.
Thanks