This is a migrated thread and some comments may be shown as answers.

Documentation

1 Answer 42 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
MWM
Top achievements
Rank 1
MWM asked on 17 Jun 2011, 03:49 PM
Hello.  At this URL:

http://www.telerik.com/help/openaccess-orm/getting-started-root-working-data.html

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.

1 Answer, 1 is accepted

Sort by
0
Pencho
Telerik team
answered on 22 Jun 2011, 07:52 AM
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,
Pencho
the Telerik team
Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
Tags
General Discussions
Asked by
MWM
Top achievements
Rank 1
Answers by
Pencho
Telerik team
Share this question
or