Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Return descriptions to the interface
Message
 
 
À
27/10/2015 17:31:47
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:
01626353
Message ID:
01626526
Vues:
26
>Start by checking the EntityState of the related entities. If they were added to your main entity before it was attached to the context, they are probably detached. If they are detached or unchanged, it won't update them in the database.

The main entity is detached and therefore the related entities are detached as well.

I am thinking is it possible to introduce some generic method in this case or I have to handle on case by case basis?

The interface only allows to add and delete, so I can delete the existing entry and add it again (the ID will be 0 in this case).

I can probably keep the deleted list in the interface and also have another Added property (not mapped) and set it in the interface when adding the entries, then do some extra handling in the repository by looping through Deleted list first (the only problem that it will be in my ViewModel, not the model class, so I would have to handle it through the API/Adapter/Repository) and then something similar for Added entries.

I can do that, but really wanted some generic approach instead of handling it on case by case basis.
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform