是否可以使用SQL将多个单独定义的局部变量作为单独的行输出到一列中?例如.
DECLARE var1 INT = 4
DECLARE var2 INT = 5
DECLARE var3 INT = 6
Run Code Online (Sandbox Code Playgroud)
然后以某种方式选择变量
SELECT (var1, var2, var3) AS UserIDs,
('u1', 'u2', 'u3') AS Names
Run Code Online (Sandbox Code Playgroud)
哪个会产生下表:
UserIDs | Names
4 | u1
5 | u2
6 | u3
Run Code Online (Sandbox Code Playgroud) 我有这个方法,我已经简化了重现问题,任何人都可以解释为什么抛出系统格式异常?
我已经尝试将@添加到格式字符串的开头,以防万一它是转义字符的问题,但它没有帮助.
private void doThing(StringBuilder builder, string inPrimaryKey) {
// At this point the builder.ToString() results in " <div class="v-group width-100 shadowed OrderPanel"
// and inPrimaryKey is "OrderId"
// Throws System.FormatException with the detail "Input string was not in a correct format."
builder.AppendFormat(@" @if (Model.{0} > 0) { <text>StateNonEditable</text> } else { <text>StateEditable</text> }", inPrimaryKey);
}
Run Code Online (Sandbox Code Playgroud)
有点背景,我们使用这段代码生成一个cshtml页面供web应用程序使用,所以stringbuilder最初包含一些html,然后我们在格式部分添加了一些C#MVC Razor.