i have 2 table and make this join it works fine and i can bind it to a datagrid view (in winforms) but how can i access to result data by foreach (how can i access to row[0][1] like data tables)??
datagridview can read all data and show ID in it but how can i read it row by row like data gridview?
void Testmethod()
{
IEnumerable<object> result;
using (var context = new TestDBEntities())
{
result = (from a in context.Table1
join b in context.Table2 on a.ID equals b.Id
select new { b.Id ,b.name });
}
}
davood
Member
240 Points
200 Posts
access to entity join result by foreach?
Mar 17, 2012 01:34 PM|LINK
hi all
i have 2 table and make this join it works fine and i can bind it to a datagrid view (in winforms) but how can i access to result data by foreach (how can i access to row[0][1] like data tables)??
datagridview can read all data and show ID in it but how can i read it row by row like data gridview?
David
ignatandrei
All-Star
134947 Points
21626 Posts
Moderator
MVP
Re: access to entity join result by foreach?
Mar 17, 2012 05:28 PM|LINK
<table><tr><td>id</td><td>name</td></tr>
@foreach(var item in result)
{
<tr><td>@item.id</td><td>@item.name</td></tr>
}
</table>