Using a Linq query, I have returned an array of two types and am trying assign each list of types to a list variable of the given type:
Model:
public class ReportViewModel
{
public List<DbTable> DbTables;
public List<Application> Applications;
}
Controller:
var ReportTablesAndSystems = (from tu in db.DbTablesUsed
join t in db.DbTables on tu.TableId equals t.TableId
join a in db.DbApplication on t.ApplicationId equals a.ApplicationId
where tu.ReportId == id
select new
{
a,
t
}).ToList();
ReportViewModel rvm = new ReportViewModel();
rvm.DbTables = //?????????
rvm.Applications = //??????
How can I set rvm.DbTables to be the list of DbTables which is held in ReportTablesAndSystems and set rvm.Applications to be the list of Applications held in ReportTablesAndSystems?
ReportTablesAndSystemscontain? I.e. aList<T>-- what isT?ReportTablesAndSystems.Select(x =>x.a).ToList()?ReportViewModelshould only consist of one list of applications, each containing a collection of tables.