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");
}
}
}
VulpesPosted Jan 17, 2012, 2:06 PM
RichPosted Jan 18, 2012, 2:29 PM
Jignesh TrivediPosted Jan 18, 2012, 4:06 AM
you can also use inbuilt function insted of loop.
string.Join(",", item.nba_Team_Names.Select(f => f.Full_Name).ToArray());
hope this help..
RichPosted Jan 17, 2012, 7:01 PM