asp.net mvc 3 razor view -> strongly typed List of tuple problem

EDIT I’ve trimmed out some of the in-progress comments here – just view the history to see. So you can make this work with 1, 2, 3 or 4 tuple generic parameters but it doesn’t work with 5. As soon as you use 5 parameters it generates code like this: public class _Page_Views_Home_Index_cshtml : System.Web.Mvc.WebViewPage<List<System.Tuple<string … Read more

Convert anonymous type to new C# 7 tuple type

Of course, by creating the tuple from your LINQ expression: public (int id, string name) GetSomeInfo() { var obj = Query<SomeType>() .Select(o => (o.Id,o.Name)) .First(); return obj; } According to another answer regarding pre-C# 7 tuples, you can use AsEnumerable() to prevent EF to mix things up. (I have not much experience with EF, but … Read more

Surprising Tuple (in)equality

Tuples require the following to be true for the objects to be considered “equal”: Must be a Tuple object with the same number of generic parameter(s) as the current object. Each of those generic parameters must be of the same type as the other. Each member of the tuple must have the same value as … Read more

Make names of named tuples appear in serialized JSON responses

For serializing response just use any custom attribute on action and custom contract resolver (this is only solution, unfortunately, but I’m still looking for any more elegance one). Attribute: public class ReturnValueTupleAttribute : ActionFilterAttribute { public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) { var content = actionExecutedContext?.Response?.Content as ObjectContent; if (!(content?.Formatter is JsonMediaTypeFormatter)) { return; } var … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)