我想查询数据库并显示结果。这是我的代码:为什么数据库查询看起来像这样?
[HttpGet]
public ActionResult Index(string message)
{
var Result = from Client in db.Clients
where Clients.ClientName == message
select Clients.ClientName;
ViewBag.Message = Result;
getCurrentUser();
return View();
}
其中消息是从输入元素获取的变量。我想用ViewBag.Message
来显示它。在页面上我看到:
SELECT [Extent1].[ClientId] AS [ClientId], [Extent1].[ClientName] AS [ClientName] FROM [dbo].[Clients] AS [Extent1] WHERE [Extent1].[ClientName] = @p__linq__0
这是什么意思?
谢谢,我现在明白了。你有权利,当我使用FirstOrDefault时,它再次回答一些奇怪的事情,但只有当我搜索现有的ClientName时才回答。 – pucek7