public void Property_values_can_be_read_and_set_using_compiled_metadata_without_reflection() { var configuration = new DbContextOptions() .UseModel(new _OneTwoThreeContextModel()) .BuildConfiguration(); using (var context = new DbContext(configuration)) { var entity = new KoolEntity15(); var property = (_KoolEntity15IdProperty)context.Model.GetEntityType(entity.GetType()).TryGetProperty("Id"); var stateEntry = context.ChangeTracker.Entry(entity).StateEntry; Assert.False(property.GetterCalled); Assert.False(property.SetterCalled); Assert.Equal(0, stateEntry[property]); Assert.True(property.GetterCalled); stateEntry[property] = 777; Assert.True(property.SetterCalled); Assert.Equal(777, stateEntry[property]); } }
public void Property_values_can_be_read_and_set_using_compiled_metadata_without_reflection() { var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseModel(new _OneTwoThreeContextModel()).UseInMemoryStore(); using (var context = new DbContext(optionsBuilder.Options)) { var entity = new KoolEntity15(); var property = (_KoolEntity15IdProperty)context.Model.GetEntityType(entity.GetType()).FindProperty("Id"); var entry = ((IAccessor <InternalEntityEntry>)context.Entry(entity)).Service; Assert.False(property.GetterCalled); Assert.False(property.SetterCalled); Assert.Equal(0, entry[property]); Assert.True(property.GetterCalled); // entry[property] = 777; // // Assert.True(property.SetterCalled); // Assert.Equal(777, entry[property]); } }
public void Property_values_can_be_read_and_set_using_compiled_metadata_without_reflection() { var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseModel(new _OneTwoThreeContextModel()).UseInMemoryStore(); using (var context = new DbContext(optionsBuilder.Options)) { var entity = new KoolEntity15(); var property = (_KoolEntity15IdProperty)context.Model.GetEntityType(entity.GetType()).FindProperty("Id"); var entry = ((IAccessor<InternalEntityEntry>)context.Entry(entity)).Service; Assert.False(property.GetterCalled); Assert.False(property.SetterCalled); Assert.Equal(0, entry[property]); Assert.True(property.GetterCalled); // entry[property] = 777; // // Assert.True(property.SetterCalled); // Assert.Equal(777, entry[property]); } }
public void Property_values_can_be_read_and_set_using_compiled_metadata_without_reflection() { var options = new DbContextOptions().UseModel(new _OneTwoThreeContextModel()); using (var context = new DbContext(options)) { var entity = new KoolEntity15(); var property = (_KoolEntity15IdProperty)context.Model.GetEntityType(entity.GetType()).TryGetProperty("Id"); var stateEntry = context.ChangeTracker.Entry(entity).StateEntry; Assert.False(property.GetterCalled); Assert.False(property.SetterCalled); Assert.Equal(0, stateEntry[property]); Assert.True(property.GetterCalled); stateEntry[property] = 777; Assert.True(property.SetterCalled); Assert.Equal(777, stateEntry[property]); } }