MVC 2 - 如何在create方法中排除多列

And*_*ans 2 c# asp.net-mvc-2-validation asp.net-mvc-2

如何在创建新客户时排除多个列?另一列是创建记录的日期 - 称为customer_dt.

public ActionResult Create([Bind(Exclude = "customer_id")] Customer customer)
{
    /* Do something here ... */
}
Run Code Online (Sandbox Code Playgroud)

Ben*_*old 11

您可以将每个字段设置为以逗号分隔的列表.例如:

 [Bind(Exclude="Customer_Id, Name,Description,Active")]
Run Code Online (Sandbox Code Playgroud)