我正在测试一个null列表.每次我找到一个,我都将它保存在一个数组中,以在验证消息中实现它.
我想要的输出看起来像这样:
需要字段1
字段4是必需的
等等...
但我似乎无法开始一条新线.
现在,它看起来像这样:
需要字段1字段4是必需的
有谁知道如何实现这一目标?
编辑:
控制器:
IDictionary<int, String> emptyFields = new Dictionary<int, String>();
foreach (Something thing in AnotherThing.Collection)
{
if (thing.Property == null)
emptyFields.add(thing.Index, thing.Name);
}
if (emptyFields.Any())
throw new CustomException() { EmptyFields = emptyFields };
Run Code Online (Sandbox Code Playgroud)
此处处理此异常:
catch (CustomException ex)
{
ModelState.AddModelError("file", ex.GetExceptionString());
return View("theView");
}
Run Code Online (Sandbox Code Playgroud)
CustomException:
public class CustomException: Exception
{
public IDictionary<int,String> EmptyFields { get; set; }
public override String Label { get { return "someLabel"; } }
public override String GetExceptionString()
{ …Run Code Online (Sandbox Code Playgroud) asp.net-mvc newline line-breaks asp.net-mvc-3 validationmessage
我正在使用SQL Server 2008 R2,我想创建一个使用参数(id)从两个表中删除的存储过程.
这是存储过程:
CREATE PROCEDURE [dbo].[sp_deleteDecision]
@ID int
AS
DELETE FROM [dbo].[tblDecisionInvolvement] as di
WHERE di.DecisionId = @ID
DELETE FROM [dbo].[tblDecision] as d
WHERE d.Id =@ID
GO
Run Code Online (Sandbox Code Playgroud)
这是我尝试创建它时出现的错误:
消息156,级别15,状态1,过程sp_deleteDecision,第6行
关键字'as'附近的语法不正确.
消息156,级别15,状态1,过程sp_deleteDecision,第8行
关键字'as'附近的语法不正确.
请注意,将更DELETE FROM改为
SELECT * FROM
Run Code Online (Sandbox Code Playgroud)
有用.
甚至可以使用参数删除某些内容吗?
TY.