前面Insus.NET實現過《使用ViewModel來實現多個Model傳送至視圖》http://www.cnblogs.com/insus/p/5594134.html 和《使用ExpandoObject來實現多個Model傳送至視圖》http://www.cnblogs.com/insus/p/ ...
前面Insus.NET實現過《使用ViewModel來實現多個Model傳送至視圖》http://www.cnblogs.com/insus/p/5594134.html 和《使用ExpandoObject來實現多個Model傳送至視圖》http://www.cnblogs.com/insus/p/5595811.html
今天我們再使用另外一個方法來實現,就是TuPle了。有關此Tuple的詳細介紹,可以參考MSDN :https://msdn.microsoft.com/zh-cn/library/system.tuple(v=vs.110).aspx
public ActionResult MultiModelViaTuple() { TableAEntity tae = new TableAEntity(); TableBEntity tab = new TableBEntity(); var a = tae.GetTableAs(); var b = tab.GetTableBs(); var tupleModel = new Tuple<IEnumerable<TableA>, IEnumerable<TableB>>(a, b); return View(tupleModel); }Source Code