Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
EF attributes that can only be changed from code
Message
De
04/04/2013 09:17:22
 
 
Information générale
Forum:
ASP.NET
Catégorie:
MVC
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01569983
Message ID:
01570051
Vues:
29
This message has been marked as a message which has helped to the initial question of the thread.
>>>>The way around this is to create a second model that has only the fields you want to update. In fact, that's probably best practice as you only query the data you really need.
>>>>
>>>
>>>Is it the only way? Say, I still want to be able to change ModifiedOn, ModifiedBy if I am editing and the first two if I am inserting.
>>>
>>>In other words, I may want to set ReadOnly attribute but conditionally.
>>
>>You could leave the EF model as is but create additional MVC models. More work though since you'd have to update the EF model from the MVC model in code....
>
>I have one MVC model which I use in both Edit and Add dialog which is the same view in my case. I don't know if I can still use the same view but different models depending on the Add vs. Edit - that may be an alternative solution.
>
>Also, the EF model is a property of my MVC model, e.g. I have Client Client property of MVC model.
>
>I also got an interesting response in my MSDN thread
>http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/656588a3-938f-489c-ac40-10c8e18057de/
>
>May be I can re-set current value to original value before save.

You could do that. But feels a bit messy - it the value should not be modifiable then it should not be modified........
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform