Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
EntityState.Detached
Message
 
 
À
01/05/2015 03:49:48
Information générale
Forum:
ASP.NET
Catégorie:
Entity Framework
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01619307
Message ID:
01619314
Vues:
26
>>Hi everybody,
>>
>>I am wondering why would our EntityState will always be Detached?
>>
>>We're not using the model classes directly in our client part of the application. In our methods we use ModelView and convert model class to a ModelView through AutoMapper and back when sending changes back to the backend.
>>
>>Is it what makes the entities detached and so that's why we're manually setting the state to Modified?
>>
>>Thanks in advance.
>
>Yes. Entities are automatically attached if they are created and returned by the object context - which wouldn't be the case if you are mapping your classes back to an EF entity.

I'm going to do more verification today. In our repository class we normally to entity = _DbSet.GetById() Then we map it to the model and send to the HTML. When get back as a model, convert back to the EF class and update. This is for the single row update.

In my case I get a list of entities as part of an object and send that whole object to the client. I receive back just the list of view models and then convert them to EF model class.

So, I am going to verify if in the first scenario our entities also detached.

In any case, is there another way of checking if the row was changed or not? Would I have to maintain a copy of the original state to compare manually?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform