Asp.net mvc 我想构建asp.net mvc应用程序,我不想依赖ID
我有一个名为country的表,它有3列:Asp.net mvc 我想构建asp.net mvc应用程序,我不想依赖ID,asp.net-mvc,Asp.net Mvc,我有一个名为country的表,它有3列: ID: generated primary key Country_Code : not primary key but it is Unique and in most of the time I will use it Instead of ID. Country_Name : the long name of the country 我不能从上面更改任何东西,这是业务要求 我使用asp.net mvc生成了CURD功能,然后我更改了代码,使其依
ID: generated primary key
Country_Code : not primary key but it is Unique and in most of the time I will
use it Instead of ID.
Country_Name : the long name of the country
我不能从上面更改任何东西,这是业务要求
我使用asp.net mvc生成了CURD功能,然后我更改了代码,使其依赖于国家代码而不是ID,因此示例中我的详细信息页面url如下所示:
something.com/country/detail/ss
我读、写和删除成功,但在编辑中我未能通过验证语句(ModelState.IsValid)。问题是,当数据来自我的编辑页面时,ID始终为0。在将ID发布到控制器时,您可以创建一个HiddenFor来保存ID。您能提供一些代码片段吗?控制器操作是什么样子的?路由表是什么样子的?