MVC LINQ 查询问题
在我的
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 返回一个具有正确结果的 IEnumerable
例如:
<%: String.Format("{0:F}", item.CREATED_BY_USER_ID) %> this is an ID
实际的用户名存储在另一个表中,我想显示该用户名
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个想法:
在查询结果中加入
Users
表,返回带有select new
构造的自定义对象:如下所示:
查看这些页面以获取更多信息:
< a href="http://msdn.microsoft.com/en-us/vcsharp/ee908647.aspx#crossjoin" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/vcsharp/ee908647 .aspx#crossjoin
C# 连接示例 (LINQ)
An idea:
Join the
Users
table in your query result returning a custom object with theselect new
construct:Something like this:
Take a look at these pages for more info:
http://msdn.microsoft.com/en-us/vcsharp/ee908647.aspx#crossjoin
C# Join Example (LINQ)