public class UserController : Controller
{
//
// GET: /User/
db_MVCEntities context = new db_MVCEntities();
public ActionResult Index(tblLogin log)
{
var login = from o in context.tblLogins
join od in context.tblReaders
on o.ReaderId equals od.ReaderId
where o.Username=="user"
select new { od.ReaderName};
if (login != null)
{
Session["uname"] = login.ToString();
return View(context.tblBookInfoes.ToList());
}
return View("Index");
}
我正在尝试加入2个表tblLogin和tblReader。 dB_MVCEntities是我的实体,它包含tblLogins和tblReaders rly。在这里,我必须从tblReader获取读者的名称,其中使用join在tblLogin表中给出用户名。 但它没有工作:( 输出似乎是
SELECT [Extent1].[ReaderId] AS [ReaderId],
[Extent2].[ReaderName] AS [ReaderName]
FROM [dbo].[tblLogin] AS [Extent1]
INNER JOIN [dbo].[tblReader] AS [Extent2] ON [Extent1].[ReaderId] = [Extent2].[ReaderId]
WHERE 'user' = [Extent1].[Username]
请帮忙