Last post Jun 09, 2009 08:33 AM by mpaterson
Jun 08, 2009 10:52 PM|mpaterson|LINK
I have an object Person with an EntityReference.
I expected that when I modified the value of the entityReference that the EntityState of the Person EntityObject would be updated to Modified.
However, this isn't happening.
The EntityState is staying Unchanged.
Does anyone know what the deal is?
Jun 09, 2009 01:23 AM|kavita_khandhadia|LINK
Are u loading the object by primary key (or some other unique comuln) and then settnig the values? as first u have to load the single entity colletion before calling update.. also can u tell me if u are updating entire collection or a single entity..
check out following sample for single entity update,.
int defImageID = Convert.ToInt32(hotelImageColl.NImageID);
newImage = new Images();
newImage.LoadByPrimaryKey(defImageID);//Here i Load the collection to be updated
newImage.CImageTitle = txtDefaultImageTitle.Text.Trim();
Jun 09, 2009 07:40 AM|maverickhyd|LINK
if your question is about ADO.NET Entity Framework and LINQ to Entities
Jun 09, 2009 08:30 AM|mpaterson|LINK
Jun 09, 2009 08:33 AM|mpaterson|LINK
I'm using the exposed property for the EntityReference (although I'm sure the same thing would happen for EntityCollections) to set the reference to a new instance of the object.
Ie. Person.Address = aAddress;
What I found through a good deal of reading was that the EntityState of Person isn't updated but the Relationship between Person and Address objects is updated.