Thread is closed for posting
2 posts, 0 answers
  1. MWM
    MWM avatar
    64 posts
    Member since:
    Jul 2007

    Posted 17 Jun 2011 Link to this post

    Hello.  At this URL:

    It reads:

    "In the following example a new car object from the SofiaCarRental database is created. On the second step a new category object from the same database is created and assigned to the newCar.Category property. The newCar object is send to the OpenAccessContext via the Add method. Finally, SaveChanges is called. In this case two object are added to the database. First, a new record is added to the Categories table, and second, a new record is added to the Cars table. It is important to note, that it is not necessary to pass the newCategory object to the OpenAccessContext's Add method in order to save it in the database, but just set it to the navigation property of the newCar object."

    Is it really the "navigation" property as indicated in the last sentence?

    Also, can you explain or point me to documentation which explains WHY it isn't necessary to make a call to "add()" for the Category here, but is just for the car object?

    Thank you.
  2. Pencho
    Pencho avatar
    22 posts

    Posted 22 Jun 2011 Link to this post

    Hi MWM,

    The idea of the example is to demonstrate that it is not needed (mandatory) to pass both objects to the OpenAccessContext. You can create an entire hierarchy (tree) of objects and just pass the root object from the hierarchy to the OpenAccessContext'Add method. OpenAccess will take care for the rest of the objects. Of course, the other approach is also valid, i.e., you can pass both objects (Car and Category) to the Add method.
    Generally, there are two types of properties - primitive and navigation. Navigation properties allow you to navigate between two entity types (e.g. Car.Category).

     Best wishes,
    the Telerik team
    Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
Back to Top