I've created the following POCO class and also made Contact.FirstName
and Contact.LastName
properties private ( these properties are mapped to appropriate properties in an Entity Framework model ).
public class Contact
{
public int ContactID { get; set; }
private string FirstName { get; set; }
public string LastName { get; private set; }
}
I expected to get an exception due to EF not being able to assign values to these two properties, but somehow EF still managed to assign values to them. How is that possible, since only code in Contact
class should have accesses to private properties?
Thank you
In environments with sufficient levels of trust, reflection can be used to access members to which one would not normally have access.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With