C #6.0 Dictionary syntax,
In C #6.0, when we use Dictionary, we can use the new syntax to simplify the program to improve efficiency.
Public Dictionary <string, object> OldToolLocations = new Dictionary <string, object> () {"ToolLocation_nbr", 1 },{ "LocationName", "A2 "}, {"Description", "C4" },{ "IsActive", true }}; public Dictionary <string, object> NewToolLocations {get; set ;}= new Dictionary <string, object> () {["ToolLocation_nbr"] = 1, ["LocationName"] = "A2", ["Description"] = "C4 ", ["IsActive"] = true };Source Code
The following uses the ASP. net mvc project. For example, the Code is feasible:
Public ActionResult CSharp6DictionaryTest () {ToolLocationEntity tlc = new ToolLocationEntity (); ViewData ["OldToolLocations"] = tlc. oldToolLocations; ViewData ["NewToolLocations"] = tlc. newToolLocations; return View ();}Source Code
Insus. NET has also written several examples in its blog. It is a one-time transmission of multiple models to the MVC view, as shown in
Using ViewModel to implement multiple models to the view http://www.cnblogs.com/insus/p/5594134.html
Http://www.cnblogs.com/insus/p/5595811.html using ExpandoObject for transferring multiple models to a view
Http://www.cnblogs.com/insus/p/5602540.html for transferring multiple models to a view using Tuple
This time, Insus. NET uses ViewData for processing. Ha ha, there are many methods. Which one can be used? You can achieve what you want to develop these things.
The following implementation View:
Effect: