Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
EntityState.Detached
Message
 
 
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:
01619314
Views:
27
>>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform