Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
EntityState.Detached
Message
From
01/05/2015 08:50:41
 
General information
Forum:
ASP.NET
Category:
Entity Framework
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01619307
Message ID:
01619318
Views:
26
This message has been marked as a message which has helped to the initial question of the thread.
>>>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?

Not sure how you'd keep a copy around if your round-tripping to the server. You could always track dirty state in angular and pass that back (or only post back if dirty)?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform