Self Tracking Entities (STE) and Partial Updates with EF4 and mVC2

I have an MVC2 application in which I am starting to use STE . I'm looking for some clarification on how updates should work.

Background:

If I have a Blog object with related category subjects and Related post / comment objects. In MVC, I present a view with the main blog object and categories, but not with related posts. When I submit a Blog object to the server, I see related categories, but not messages (because they were not in the view) in the entity that is serialized on the server. In addition, the Blog object has a change status of "Added."

Then I try to call Applychanges(), and SaveChanges()at the site blog for the update, and it fails because of the FK relationship with the messaging and the existence of related records in the database, but is not tied to I send back.

With further testing ... If I grab the current instance of the Blog object (with all associated FK objects) when connected to the server (state = unchanged), change the property (state = Modified) and update it to work as expected.

So my questions are: If I have related objects that do not appear in the view and therefore do not come back with the Blog object, if the update works?

Blog "", ""? , , , ApplyChanges/SaveChanges(), , .

ApplyChanges()/SaveChanges(), , , ?

+3
4

:

Applychanges() SaveChanges() - FK , , , .

( "", "" ). , , , FK.

:

Blog "", 'Modified'? , "" changestate , ApplyChanges/SaveChanges() .

, , , ? STE , . STE , , , , .

:

ApplyChanges()/SaveChanges() , , , ?

, ( ) ApplyChanges()/SaveChanges() , , , ( , , ).

+1

, , STE EF4 , , .

MVC . , "" , EditController View.

( , , ) ( ), .

, , , Controller, , , ​​ Get. , , , , Get.

EF4 STE , , . , , . MVC STE ...

+1

- . , , STE , .

, ObjectStateManager STE.. , , , , , STE STE ( , ).

, , :

, STE .

, , , STE ...

Diego Vega ( EF)

STE , POCO. , API ObjectContext ObjectStateManager, DetectChanges, , SaveChanges.

, API STE , AcceptAllChanges ( , SaveChanges ObjectStateManager Unchanged), , STE.

http://social.msdn.microsoft.com/Forums/en/adonetefx/thread/557e6db0-51df-45e5-a2e9-c31995969554

,

0

I do not believe that I have ever said that STEs are not ready for the real world. They simply will not be for everyone. They are a pretty good tool for dataset / dataset users who just want something that will work just as easily. For these users (and there are a lot of them), placing STE objects in the client application is not evil. Perhaps he already has both sides of the pipe.

0
source

Source: https://habr.com/ru/post/1729580/


All Articles