ASP.Net Razor 语法显示 SQL SelectQuery 值
ASP.Net Razor Syntax display SQL SelectQuery values
我正在尝试将多个计数查询合并为一个,到目前为止在 SSMS 中获得了预期结果,但我需要在我的网页中显示它,该网页采用 ASP.Net Razor 语法。
var selectQuery= SELECT COUNT (Host) AS Total,
COUNT CASE (WHEN OS LIKE '1909%' THEN 1 END) AS Win101909,
COUNT CASE (WHEN OS LIKE '20H2%' THEN 1 END) AS Win1020H2
FROM Computers;
var ComputerCount = db.QueryValue(selectQuery);
<p>@ComputerCount.Total</P>
<p>@ComputerCount.Win101909</P>
<p>@ComputerCount.Win1020H2</P>
我是不是做错了?
我找到了解决方案如下:
变化:db.QueryValue(selectQuery);
收件人:db.QuerySingle(selectQuery);
它可能对其他人有帮助
我正在尝试将多个计数查询合并为一个,到目前为止在 SSMS 中获得了预期结果,但我需要在我的网页中显示它,该网页采用 ASP.Net Razor 语法。
var selectQuery= SELECT COUNT (Host) AS Total,
COUNT CASE (WHEN OS LIKE '1909%' THEN 1 END) AS Win101909,
COUNT CASE (WHEN OS LIKE '20H2%' THEN 1 END) AS Win1020H2
FROM Computers;
var ComputerCount = db.QueryValue(selectQuery);
<p>@ComputerCount.Total</P>
<p>@ComputerCount.Win101909</P>
<p>@ComputerCount.Win1020H2</P>
我是不是做错了?
我找到了解决方案如下:
变化:db.QueryValue(selectQuery);
收件人:db.QuerySingle(selectQuery);
它可能对其他人有帮助