I am using linq join to get data from two tables. But my second table has multiple records corresponding to first table. And i want only first record from second table .
Table student
id name
1 a1
2 b1
Table images
id image studentId
1 1.jpg 1
2 2.jpg 1
3 3.jpg 2
4 4.jpg 2
Result should be
id name image
1 a1 1.jpg
2 b1 3.jpg
I am using the following code. and its returning four records.
public IEnumerable<StudentBean> getStudent()
{
return (from p in context.student
join r in context.images
on p.id equals r.studentId
select new StudentBean
{id=p.id,
name =p.name,
image=r.image
}).ToList<StudentBean>();
}