Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you have such specific requirement you should start by modifying your WCF service to not accept fields which user cannot modify. That leads to two simple DTOs:</p> <pre><code>public class MainTypeUpdateDto { public Guid ID { get; set; } public String Field1 { get; set; } public String Field2 { get; set; } public List&lt;DetailsTypeUpdateDto&gt; Details { get; set; } } public class DetailsTypeUpdateDto { public Guid MainTypeID { get; set; } public Guid SomeIdentityID { get; set; } public String Detail { get; set; } } </code></pre> <p>All other fields either cannot be updated or should be handled by your server side logic.</p> <p>Now when you receive dtos you can map them back to real entity objects. Based on user role you will know which fields and details you must set. You have two options to force EF to save only fields you want:</p> <ul> <li>First create object graph with <code>MainType</code> and related details. Set only Ids in these entities and attach <code>MainType</code> entity to context. After that set all updatable fields to current values. Do not change state of any entity.</li> <li>Create object graph with <code>MainType and all related details and set all Ids and all updatable fields. After that attach</code>MainType` entity to the context and <a href="https://stackoverflow.com/questions/5407885/modify-field-with-entity-framework-without-entityobject/5410375#5410375">manually set state</a> for each modified property (on each entity).</li> </ul> <p>You can need some additional logic if user can also remove or add details.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload