Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For scalar and complex properties you can use the following to extract the changed property names of an entity <code>myEntity</code>:</p> <pre><code>var entry = context.Entry(myEntity); var namesOfChangedProperties = entry.CurrentValues.PropertyNames .Where(p =&gt; entry.Property(p).IsModified); </code></pre> <p>A few things to note here:</p> <ul> <li><p><code>CurrentValues.PropertyNames</code> only contains scalar and complex properties, not navigation properties.</p></li> <li><p>Complex properties means: Only the name of the complex property which is declared on the entity, not the actual individual properties of the complex type itself, for example: If you have this model...</p> <pre><code>[ComplexType] public class Address { public string Country { get; set; } public string City { get; set; } } public class Person { public int Id { get; set; } public string Name { get; set; } public Address Address { get; set; } } </code></pre> <p>... then, if <code>myEntity</code> is a <code>Person</code>, <code>CurrentValues.PropertyNames</code> would contain "<strong>Id</strong>", "<strong>Name</strong>" and "<strong>Address</strong>" but not "<strong>Address.Country</strong>" or "<strong>Address.City</strong>" (nor "<strong>Country</strong>" or "<strong>City</strong>").</p></li> <li><p>If a complex property is marked as modified (<code>.IsModified</code> in the code above is <code>true</code>) then this means that either the reference (<code>Person.Address</code> in the example above) has changed, no matter if actually the property values (<code>Country</code> and <code>City</code>) inside of the complex type have changed or not. Or that any of the properties of the complex type has changed (<code>Country</code> or <code>City</code> has changed). I believe it's not possible to find out which one, because EF always sends an UPDATE command for <em>all</em> complex type properties to the database, even if only one property has changed and the other remained unchanged. I would conclude from this that EF doesn't track changes of individual complex type properties.</p></li> </ul>
    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.
    3. 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