问题描述
大家好..........
我有一个像list这样的linq变量...它从数据库的两个以上的表中检索一些值.............我如何创建一个存储值列表的viewmodel以及如何分配这个值从控制器到该视图模型的列表.........请帮助我............
Hi everyone..........
I have a linq variable like list ...it retrieves some values from more than two tables from database ............ how can i create a viewmodel to store list of values and how can i assign this list to that view model from controller......... please help me............
推荐答案
public class aaa
{
table1filrd1{get;set;}
table1filrd2{get;set;}
table1filrd3{get;set;}
table2filrd1{get;set;}
table2filrd2{get;set;}
table2filrd3{get;set;}
}
或者您可以开发单独的模型并将其分组为单个班级
or you can develop a separate models and club them in single class
public class a{....}
public class b{....}
public class c
{
List<a> aa {get;set;}
List <b> bb {get;set;}
}
</a>
最后一个选项是使用ViewData传递两个列表,但不建议
您可以参考
http://www.codeproject.com/script/Answers/Post.aspx?aid=485966 [^ ]
and last option is pass the both list using ViewData but it is not advisable
you can refer
http://www.codeproject.com/script/Answers/Post.aspx?aid=485966[^]
这篇关于将值分配给Viewmodel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!