 |
BOOK: Beginning ASP.NET 4 : in C# and VB
 | This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 26th, 2010, 03:17 PM
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
question for ADO.NET chapter 14
hello all. i have a question that is confusing me. On page 482 the book writes that the tables(Genre and review) on figure 14.2 named classes...But on How it works on page 484 on second paragraph i read "objects". does it referring to the previous thing?(classes) ? does it the same as oo programming where we have objects that created by classes?
also i want to know where is used the navigation properties below the classes.
thanks
Last edited by stram; September 26th, 2010 at 03:48 PM..
|

September 27th, 2010, 02:26 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Quote:
does it the same as oo programming where we have objects that created by classes?
|
Yes, it's the same. Based on the database, Visual Studio generates classes for you. The LINQ to SQL run time then creates objects based on these class definitions.
Quote:
also i want to know where is used the navigation properties below the classes.
|
This makes no sense to me, so I am afraid I can't answer it.
Cheers,
Imar
|

September 27th, 2010, 04:34 AM
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
hello Imar. thanks for the first answer.
for the second question:
i can't understand what is navigation properties? for example genre has navigation properties Reviews. did it created when I create the relationship between two tables?
|

September 27th, 2010, 04:51 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi stram,
It doesn't do that when you create the relationship in the database, but when you create the model in Visual Studio. When you create the model, Visual Studio analyses your database and detects the relationship. It then creates a Navigation property in both classes; one a single instance, the other a collection (so you can navigate from a genre to its reviews - myGenre.Reviews - and back - myReview.Genre).
Hope this helps,
Imar
|

September 27th, 2010, 05:28 AM
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by Imar
(so you can navigate from a genre to its reviews - myGenre.Reviews - and back - myReview.Genre).
|
can you give me an example where it used? or an example in the book?
thanks
|

September 27th, 2010, 06:00 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
One place where it's used is in the Code Behind of AllByGenre.aspx:
Code:
Dim allGenres = From genre In myEntities.Genres
Order By genre.Name
Select New With {genre.Name, genre.Reviews}
Code:
var allGenres = from genre in myEntities.Genres
orderby genre.Name
select new { genre.Name, genre.Reviews };
Cheers,
Imar
|
The Following User Says Thank You to Imar For This Useful Post:
|
stram (September 27th, 2010)
|

September 27th, 2010, 06:44 AM
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
ok Imar I understand it.
thanks 
|
|
 |
|