I'm using the following code to join 2 tables and return their results to the View
.
var Results = (from post in DbContext.posting_file
join reader in DbContext.user_master_postings on post.id equals reader.posting_id
join file in DbContext.postings_title on post.id equals file.id
orderby reader.date_created descending
select new { file.title, reader.date_created, reader.department, reader.user_name }).Take(5).ToArray();
When running the foreach loop in the view.
@foreach (var item in ViewBag.Results){
@item
}
I get the following result.
{ title = Title 1, date_created = 21/08/2018, department = Audit, user_name = Chetty } { title = Title 2, date_created = 21/08/2018, department = Audit, user_name = Pal } { title = Title 3, date_created = 21/08/2018, department = Audit, user_name = Chetty } { title = Title 4, date_created = 21/08/2018, department = Corporate, user_name = Kau }
What I want is the result to be in array format so that I can loop over the results and populate it inside the table. How can I do this?