Data Access has been discontinued. Please refer to this page for more information.

Retrieving Members Based On Their State

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

Sometimes it can be useful to find exactly which properties for a given entity have been changed. The OpenAccessContext class exposes the GetMemberNames method, which returns a collection of members' names for a given instance based on the provided member state.

using (EntitiesModel dbContext = new EntitiesModel())
   Category category = dbContext.Categories.FirstOrDefault();
   category.CategoryName = "New Category Name";

   IEnumerable<string> modifiedMembers = dbContext.GetMemberNames(category, 
Using dbContext As New EntitiesModel()
    Dim _category As Category = dbContext.Categories.FirstOrDefault()
    _category.CategoryName = "New Category Name"

    Dim modifiedMembers As IEnumerable(Of String) = dbContext.GetMemberNames(_category, 
End Using

The ObjectState argument can have the following values:

  • Clean - the property is not modified.
  • Dirty - the property is modified.
  • NotLoaded - the property is not loaded from the database.
  • New - when you initialize a new instance and add it to the context, all properties are in state New.
  • Deleted - when you pass an existing category to the Delete method of the context, all properties are in state Deleted.