I try to include anonymous type like this :
I want all incomelist
attributes in addition to CompanyTitle
,PeriodTypeName
)
var incomeList = ctx.IncomeLists.Include(i => new
{
CompanyTitle = i.CompanyId.ToString() + "/" + i.Company.CompanyName,
PeriodTypeName = i.ListPeriods.Select(lp => lp.PeriodType.PeriodTypeName)
}).ToList()
My model section like this :
but i get the following exception :
The Include path expression must refer to a navigation property
defined on the type. Use dotted paths for reference navigation
properties and the Select operator for collection navigation
properties. Parameter name: path
The result should be the datasource to Gridview.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…