简体   繁体   English

如何查询数据库以放入Dropdownlist MVC剃须刀ASP.NET C#

[英]How to query database for put into Dropdownlist MVC razor ASP.NET C#

How to query database for put into Dropdownlist MVC razor ASP.NET C 如何查询数据库以放入Dropdownlist MVC剃须刀ASP.NET C

I would like to put this query into drowdownlistt. 我想将此查询放入drowdownlistt。 I tried many way to do that but I always get something like "{SELECT [Extent1].[ID] AS [ID], . . . (@p__linq__0 IS NULL))}" 我尝试了很多方法来做到这一点,但是我总是得到类似“ {SELECT [Extent1]。[ID] AS [ID],...(@ p__linq__0 IS NULL))}”的内容。

but I want to get the value(the result) of this query 但我想获取此查询的值(结果)

so, how can I solve this problem? 那么,我该如何解决这个问题呢?

here is my query: 这是我的查询:

var listSector = db.SectorUserLinks.Include(s => s.Sector).Where(s => s.UserId == USERID);

thank you 谢谢

要阻止查询向您显示SQL,请在末尾放置ToList() ,如下所示

var listSector = db.SectorUserLinks.Include(s => s.Sector).Where(s => s.UserId == USERID).ToList();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从ASP.NET MVC和C#中的数据库中为下拉列表选择值? - How do I select a value for a dropdownlist from a database in ASP.NET MVC and C#? 如何在 DropDownList 中保留空格 - ASP.net MVC Razor 视图 - How to retain spaces in DropDownList - ASP.net MVC Razor views 如何在ASP.NET Razor MVC 5中创建禁用的下拉列表 - How to create dropdownlist Disabled in ASP.NET Razor MVC 5 使用C#asp.net MVC代码优先方法在Razor中验证@ Html.DropDownList和@ Html.DropDownListFor - Validation for @Html.DropDownList and @Html.DropDownListFor in Razor using C# asp.net mvc code first approach 在ASP.NET MVC C#中绑定2 Dropdownlist - Binding 2 Dropdownlist in ASP.NET mvc c# ASP.NET MVC C#-DropDownList SelectedIndexChanged不触发 - Asp.net MVC C# - DropDownList SelectedIndexChanged not firing c#ASP.net MVC中的DropDownlist和列表问题 - DropDownlist and List issue in c# ASP.net MVC 从下拉列表 ASP.NET MVC 5 和 C# 中删除项目 - Remove item from dropdownlist ASP.NET MVC 5 and C# 在 C# 和 ASP.NET MVC 剃刀视图中使用数据库中的值填充 css 属性 - Populate css property with value from database in C# & ASP.NET MVC razor view 从数据库asp.net C#中查询为gridview中的dropdownlist设置ToolTip - set ToolTip for dropdownlist inside gridview from query from database asp.net C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM