在C#中使用字符串值作为变量名称
我的字符串正在剃须刀页面传递给我的控制器。该字符串包含用户选择的8个可能布尔值之一的名称。我试图在SQL Server查询中使用此布尔名称,如下所示。
try
{
var test = await _context.GuestModel
.Include(r => r.PatientModel)
.OrderByDescending(r => r.GuestLastName)
.Where(r => r.booleanName == true)
.ToListAsync();
return test;
}
Booleanname是包含我需要使用的布尔名称的字符串,但是到目前为止,我无法成功访问该信息。
I have a string that is being passed to my controller in Razor Pages. This string contains the name of one of 8 possible Booleans as selected by the user. I am attempting to use this Boolean Name in a SQL server query as shown below.
try
{
var test = await _context.GuestModel
.Include(r => r.PatientModel)
.OrderByDescending(r => r.GuestLastName)
.Where(r => r.booleanName == true)
.ToListAsync();
return test;
}
booleanName is the string containing the Boolean Name I need to use, but so far I have not been able to access that information successfully.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果/else 块,请使用
switch
或blocks从基于字符串的查询中的八个可能版本之一中选择。
Use a
switch
orif/else
blocks to pick from one of eight possible versions of the query based on the string.