Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 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
  #1 (permalink)  
Old July 23rd, 2008, 12:21 AM
Registered User
 
Join Date: Jul 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default collections help

essentially i'm trying to follow the 3-tier architecture used in this book but am a bit lost with the whole collections thing. i'm trying to get some data but I have a 3 table query. the query gets the fixture for the season, one getting from the game table, the full team names from the team table and venue name from venue table. I've made these details classes.

protected virtual AFLGameDetails GetAFLGameFromReader(IDataReader reader){
AFLGameDetails aflGame = new AFLGameDetails(

(int)reader[" AflGame_id"],
(DateTime)reader["Date"],

(int)reader["Round"],
reader["Home"].ToString(),

reader["Away"].ToString(),
(decimal)reader["HomeLine"],

(decimal)reader["AwayLine"],
(bool)reader["Day_Night"],

(int)reader["Crowd"],
reader["Venue_id"].ToString(),

reader["AddedBy"].ToString(), (DateTime)reader["AddedDate"]);
return aflGame;}



and



protected virtual TeamDetails GetTeamFromReader(IDataReader reader){
TeamDetails team = new TeamDetails(

reader["Team_id"].ToString(),
reader["Team"].ToString(),

reader["AddedBy"].ToString(), (DateTime)reader["AddedDate"]);
return team;}



plus one for venue but thats pretty much the same as team.

however my query is as such



SELECT AFLGame.date, AFLGame.round, home.team AS Home, away.team AS Away, Venue.venue

FROM AFLGame INNER JOIN

Venue ON AFLGame.venue_id = Venue.venue_id INNER JOIN

Team AS home ON AFLGame.home = home.team_id INNER JOIN

Team AS away ON AFLGame.away = away.team_id



i know we have to right a method like the one below but i need some confirmation as to whether the collections i've written above is meant to match my sql query or is there some other way i'm meant to be doing it. i haven't been able to do any work on it the last few days and any help would be appreciated.



protected virtual List<AFLGameDetails> GetAFLGameCollectionFromReader(IDataReader reader)
{

List<AFLGameDetails> aflGame = new List<AFLGameDetails>();while (reader.Read())
aflGame.Add(GetAFLGameFromReader(reader));

return aflGame;
}



thanks

ben


  #2 (permalink)  
Old July 23rd, 2008, 06:36 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Benny,

I ran a quick site builder against a rough version of the tables that you've defined above. You can pick it up and take a look at the code which seems to work as you intend based on the initial requirement:

http://www.originaltalent.com/downloads/AFL.zip

Cheers

jimi

http://www.originaltalent.com
  #3 (permalink)  
Old July 23rd, 2008, 06:05 PM
Registered User
 
Join Date: Jul 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

if i learnt linq would that make this heaps easier?

  #4 (permalink)  
Old July 26th, 2008, 01:30 AM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Quote:
quote:Originally posted by bennyt
 if i learnt linq would that make this heaps easier?

Yes and no.

Joins are still tricky using LINQ to SQL, just like they are with T-SQL. But joins are a piece of cake with LINQ To Entities, and you'll need to learn LINQ to use it.

Believe me, LINQ to Entities will be totally revolutionary. That's why learning LINQ right now is a worthwhile endeavor.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Collections and Recordsets MLC1985 Beginning VB 6 10 August 1st, 2007 09:13 AM
Collections in C#? shenku C# 1 August 17th, 2005 06:16 AM
Collections question GregV VB.NET 2002/2003 Basics 0 August 6th, 2003 12:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.