views:

274

answers:

0

When I create strongly typed View in Asp.net mvc 2, .net 4.0 with model type Tuple I get error when Tuple have more than 4 items

example 1: type of view is Tuple<string, string, string, string> (4-tuple) and everything works fine

view:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/WebUI.Master" Inherits="System.Web.Mvc.ViewPage<Tuple<string, string, string, string>>" %>

controller:

var tuple = Tuple.Create("a", "b", "c", "d");
return View(tuple);

example 2: type of view is Tuple<string, string, string, string, string> (5-tuple) and I have this error: Compiler Error Message: CS1003: Syntax error, '>' expected

view:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/WebUI.Master" Inherits="System.Web.Mvc.ViewPage<Tuple<string, string, string, string, string>>" %>

controller:

var tuple = Tuple.Create("a", "b", "c", "d", "e");
return View(tuple);

example 3 if my view model is of type dynamic I can use both 4-tuple and 5-tuple and there is no error on page

view:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/WebUI.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

controller:

dynamic model = new ExpandoObject();
model.tuple = Tuple.Create("a", "b", "c", "d");
return View(model);

or

view:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/WebUI.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

controller:

dynamic model = new ExpandoObject();
model.tuple = Tuple.Create("a", "b", "c", "d", "e");
return View(model);

Even if I have something like Tuple<string, Tuple<string, string, string>, string> 3-tuple and one of the items is also a tuple and sum of items in all tuples is more than 4 I get the same error, Tuple<string, Tuple<string, string>, string> works fine