Hey guys
I'm using EF and some related tables and I'm supposed to get the result from all of them and put it on a grid. The tables are Tara(ID, Name), Judet(ID,ID_Tara, Name), Oras(ID, ID_Judet, Name), CodPostal(ID, ID_Oras, CodPostal), Adresa(ID, ID_CodPostal, ID_Oras, Detalii). I hope you understand the relationship betwen them.
Now I must write a query with the parameter ID(Adresa) and bind the result to the datagrid and I must use Include(). I have the example below:
public List<Adresa> GetFullAddress(int id)
{
var adresa = be.Adresa.Include("CodPostal.Oras.Judet.Tara").Where(a => a.ID == id);
return adresa.ToList();
}
The column definitions are the following
What I don't know is what to enter as FieldName except for the first one because the other are in the related tables
<grid:AgDataGrid.Columns>
<grid:AgDataGridTextColumn TextWrapping="Wrap" FieldName="Detalii" MinColumnWidth="70" HeaderStyle="{StaticResource ColumnHeaderStyleBlue}"/>
<grid:AgDataGridTextColumn TextWrapping="Wrap" FieldName="CodPostal" MinColumnWidth="70" HeaderStyle="{StaticResource ColumnHeaderStyleBlue}"/>
<grid:AgDataGridTextColumn TextWrapping="Wrap" FieldName="Oras" MinColumnWidth="70" HeaderStyle="{StaticResource ColumnHeaderStyleBlue}"/>
<grid:AgDataGridTextColumn TextWrapping="Wrap" FieldName="Judet" MinColumnWidth="70" HeaderStyle="{StaticResource ColumnHeaderStyleBlue}"/>
<grid:AgDataGridTextColumn TextWrapping="Wrap" FieldName="Tara" MinColumnWidth="70" HeaderStyle="{StaticResource ColumnHeaderStyleBlue}"/>
</grid:AgDataGrid.Columns>
I am using services
private void bsc_GetFullAddressCompleted(object sender, GetFullAddressCompletedEventArgs e)
{
gridBorderouTara.DataSource = e.Result;
}
I solved the problem using stored procedure but I am supposed to do it this way :(
Thank you and I hope I gave enough information