[RESOLVED]Cross tables and Index function on the controller

I’m sure someone has already answered this, but I can’t find the way to do this right.

I am building an MVC 5 app and in one of the columns, we have an int, but what I want to display is the string that comes from another table which corresponds to that column. I know I can use a ViewBag in the Edit or Create functions, but I have the feeling
it won’t work the same way in the index.

Can someone point me in the right direction so I can suss it out?

Thanks in advance….


I wrote something in LinqPad which pulls back most of the data I want.

var calls = (from c in Vanguard join r in Van_reason on c.Contact_reason equals r.Valcod where c.Cdts.CompareTo(DateTime.Now.AddDays(-1).ToString("yyyyMMddHHmmss")) >= 0 select new {c.Eid, c.County, c.Cpers, c.Cterm, c.Contact_reason, r.Eng_valcod});


But, will this work in the index the way that I want? In there, I’m only using a few of the columns anyway, so that shouldn’t be too big of an issue.

Hi brandrui,

For this requirement, you just need to join these tables’ data. (As you mentioned in your reply)

If you don’t want to get all columns/fields data, you just need get the necessary data by using select.

There is a link that can help you:

# join clause (C# Reference)


Best Regards

Starain Chen

Leave a Reply