本文介绍了我如何...在MVC4中动态地向模型类添加新字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi
in have one table in my db, Table Name is Students
Column Name DataType
ID int
FieldName varchar(50)
and i insert some records in that table
below :
ID FieldName
1 ID
2 FirstName
3 LastName
4 Standard
5 Section
6 School
7 City
I insert 7 records
My Model Class
public class Studentdetails
{
public int UID { set; get; }
[Required]
public string ID { set; get; }
[Required]
public string FirstName { set; get; }
[Required]
public string LastName { set; get; }
[Required]
public string Standard { set; get; }
[Required]
public string Section { set; get; }
[Required]
public string School { set; get; }
[Required]
public string City { set; get; }
}
My Requirement is When I add New New Record in Students table
that will added dynamically in to Studentdetails class as new property
Ex Suppose i add new record like phno then my table come like this
ID FieldName
1 ID
2 FirstName
3 LastName
4 Standard
5 Section
6 School
7 City
8 Phno
i want my model automatically change in to below like this
public class Studentdetails
{
public int UID { set; get; }
[Required]
public string ID { set; get; }
[Required]
public string FirstName { set; get; }
[Required]
public string LastName { set; get; }
[Required]
public string Standard { set; get; }
[Required]
public string Section { set; get; }
[Required]
public string School { set; get; }
[Required]
public string City { set; get; }
public string Phno { set; get; }
}
anybody know pls answer this.........
推荐答案
这篇关于我如何...在MVC4中动态地向模型类添加新字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!