 |
| ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 3.5 Basics 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
|
|
|
|

April 30th, 2009, 11:32 AM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
nTier structure and linked table
I've downloaded great example of Imar Spaanjaar.
http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=476
I've a problem with linked record...
I create an entityA with records of tableA of the DB and entityB with records of tableB of the DB...
but if 2 tables are link (INNER JOIN in DB) how can I use the records of table2 when I work with an entity of table1??
tableA entityA = new tableA();
entityA = tableAManager.GetItem(id);
how Can I use the fields of entity of tableB in entityA?
Thanks
|
|

April 30th, 2009, 11:03 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
|
|
I don't know the syntax offhand but look up ADO.NET relations. Basically the relationships in your DB get lost when you transfer the data into your dataset, and you have to recreate them in code, ie you have to create the same relationship between entityA and entityB that the two database tables have. Once you do that, they're like one big table and you can grab the information easy.
__________________
-------------------------
Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe
When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper
Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
|
|

May 1st, 2009, 05:39 AM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for your reply!!!
Can you send me an easy example of what I've to do when I've create entities, classDB and classManager ... for manage JOINED fields in my "master entity"
Thanks
|
|

May 3rd, 2009, 05:48 PM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I've tried to see the example ... in Contact Person entity I've
/// <summary>
/// Gets or sets a collection of <see cref="Address" /> instances for the contact person.
/// </summary>
public AddressCollection Addresses { get; set; }
/// <summary>
/// Gets or sets a collection of <see cref="PhoneNumber" /> instances for the contact person.
/// </summary>
public PhoneNumberCollection PhoneNumbers { get; set; }
/// <summary>
/// Gets or sets a collection of <see cref="EmailAddress" /> instances for the contact person.
/// </summary>
public EmailAddressCollection EmailAddresses { get; set; }
These are entities linked ... but I would like to know how to read the items of linked entities using something like this
mycontactperson = ConctatManager.Load(ID)...
Thanks
|
|

May 4th, 2009, 03:36 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
These are just publc properties for to the associated items. Look at the GetItem method of the ContactPersonManager to see how they are filled.
Cheers,
Imar
|
|

May 4th, 2009, 03:56 AM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for your reply! Now I see
but do you confirm me that with this method Can I get also "linked" (with join) fields ...of other tables?
Thanks
|
|

May 4th, 2009, 04:21 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
You could certainly do that, as long as the query (direct SQL or a stored procedure) returns data that your object model understands....
Imar
|
|

May 4th, 2009, 04:36 AM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes... this is my problem!!
I don't know if I've to do
1) create a SP with all JOIN and fill a ContactPerson entity where I've added X new proprieties with X fields (the JOINED fields of other tables/entities) that I want to have in my ContactPerson Entity
2) manage the JOINED fields in each entity
Could you send me a simple example?
I hope that you can help me!
Thanks
|
|

May 4th, 2009, 04:43 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
I'm not sure I understand the question and your two options. Can you elaborate?
Imar
|
|

May 4th, 2009, 04:49 AM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I'm a little confused about this :-(((
could you send me a simple example (not a working example) ... I would like only to know the right solution!!
Thanks for help me!
|
|
 |