how to create a list using 2 table and 2 model class in mvc entityframework
这里我不想创建另一个模特类 假设 modelclass 1 int nameid string name1 model class2 int id2 字符串的位置 i需要一个列表,它应该采用nameid并从模型类和相应的clumn中放置相应的clumn值。 我尝试了什么: 无法返回列表,我不想创建我想要的任何模型类使用现有的
here i dont want to create another model class suppose modelclass 1 int nameid string name1 model class2 int id2 string place i want a list it should take nameid and place value from model class and respective clumn from respective table. What I have tried: unable to return list ,i dont want to create anyothe model class i want to use the existing one
推荐答案如果要创建类型列表,则必须在List中指定类型。例如,您需要Model Class 1的列表,然后您必须说List< modelclass1> ;. 在您的情况下,您必须创建一个ModelView类。 If you want to create a list of a type then you have to specify the type in List. For example , you want list of Model Class 1 then you have to say List<modelclass1>. In your case, you have to create a ModelView class. public class ModelViewClass { public int nameid {get;set;} public string place {get;set;} }
这里你没有创建一个新的模型类,而是一个视图模型类来处理视图。 这是MVC的做事方式。
Here you are not creating a new model class but a view model class to work with view. This is the MVC way of doing things.
更多推荐
如何在mvc entityframework中使用2表和2模型类创建列表
发布评论