Using the simple example below, what is the best way to return results from multiple tables using Linq to SQL?
Say I have two tables:
Dogs: Name, A
If you have a relationship setup in your database with a foriegn key restraint on BreedId don't you get that already?
So I can now call:
internal Album GetAlbum(int albumId)
{
return Albums.SingleOrDefault(a => a.AlbumID == albumId);
}
And in the code that calls that:
var album = GetAlbum(1);
foreach (Photo photo in album.Photos)
{
[...]
}
So in your instance you'd be calling something like dog.Breed.BreedName - as I said, this relies on your database being set up with these relationships.
As others have mentioned, the DataLoadOptions will help reduce the database calls if that's an issue.