LINQ query from multiple tables

L

Luna

I have the following 2 database tables
Category
----------
Id
Name


Photo
----------
Id
CatId
Title

There's a relationship between
Category.Id = Photo.CatId

The class generated by dbml has the following properties
Class Category
{
int Id
string Name
System.Data.Linq.EntitySet<Photo> Photos
}

Class Photo
{
int Id
int CatId
string Title
Category category
}

I would like to know how to write a LINQ query that will return
3 categories with 10 photos in each

do I need to write a query to the categories and then a loop to get photos
for each category?
Im not sure how to populate EntitySet<Photo> Photos. Tried ToList but it
didn't work

Can this be done with a single query?

thx

Luna
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top