Below within my method I have the statement nba_Team_Names nbaTeam = item.nba_Team_Names.FirstOrDefault();
This seems to return the first element or string in the sequence, but how do I return the entire sequence?
public void GetTeams()
This seems to return the first element or string in the sequence, but how do I return the entire sequence?
public void GetTeams()
{
IQueryable team = from t in db.Sports_Leagues_Level
.Include("nba_Team_Names")
select t;
foreach (Sports_Leagues_Level item in team)
{
Console.WriteLine(item.ID);
nba_Team_Names nbaTeam = item.nba_Team_Names.FirstOrDefault();
if (nbaTeam != null)
{
Console.WriteLine(nbaTeam.Full_Name);
}
else
{
Console.WriteLine("No Nba Team");
}
}
}

VulpesRank #55 · 29.2K reputationPosted Jan 17, 2012, 9:06 AM EST
Rich83 reputationPosted Jan 17, 2012, 2:01 PM EST
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 17, 2012, 11:06 PM EST
you can also use inbuilt function insted of loop.
string.Join(",", item.nba_Team_Names.Select(f => f.Full_Name).ToArray());
hope this help..
Rich83 reputationPosted Jan 18, 2012, 9:29 AM EST