views:

67

answers:

1

In my

public ActionResult Active()
{
    var list = _entity.CALL_UP.Where(s => s.STATE == ICallUpsState.FULLY_SIGNED)
                              .Where(f => f.START_DATE <= DateTime.Today 
                                       && f.END_DATE >= DateTime.Today)
                              .ToList();
    return View(list);
}

This returns an IEnumerable<CallUP> with the correct result, but I want USER_ID to be displayed as User Name which is in another table. How do I do that?

For Example:

<%: String.Format("{0:F}", item.CREATED_BY_USER_ID) %> this is an ID

the actual user name is stored in another table, I want to display that user name instead

A: 

An idea:

Join the Users table in your query result returning a custom object with the select new construct:

Something like this:

// Join on the ID properties.
var query = from c in list
            join u in users on c.CREATED_BY_USER_ID equals u.ID
            select new { c.STATE, c.Property2, c.Property3, u.Name };

Take a look at these pages for more info:

http://msdn.microsoft.com/en-us/vcsharp/ee908647.aspx#crossjoin

C# Join Example (LINQ)

Leniel Macaferi