Use Tuple to transmit multiple models to the view.
Previous Insus. NET Implementation of "using ViewModel to achieve multiple models to the view" http://www.cnblogs.com/insus/p/5594134.html and "using ExpandoObject to achieve multiple models to the view" http://www.cnblogs.com/insus/p/5595811.html
Today we will use another method to implement TuPle. For more information about this Tuple, see MSDN: https://msdn.microsoft.com/zh-cn/library/system.tuple (v = vs.110). aspx
Use the data prepared in the first article. The difference is in the Controller and view.
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
Code #1 marked above:
Demo result: