Hi!
I was wandering how to join one or more tables and populate my enumerable result with my class model.
My Class Model - TerrytoryModel
Table - Territory, Region
1 - The result of the join is a anonymous enumerable list.
2 - Populate a class with the result.
var myTerritories = (from te in lObjDC.Territories
join re in lObjDC.Regions
on te.RegionID equals re.RegionID
select new
{
TerritoryID = te.TerritoryID,
TerritoryDescription = te.TerritoryDescription,
RegionDescription = re.RegionDescription
}
).Select(p => new TerritoryModel(p.TerritoryID, p.TerritoryDescription, p.RegionDescription));
3 - The result of myTerritories is a Enumerable list of TerritoryModel.
PS:
Territory and Region are tables from the Northwind database.
Nenhum comentário:
Postar um comentário