Serializing Anonymous DataMemeber

I've been working win MVC Web API and encountered an annoying problem. It does not, by default serialize anonymous data members.

When you try to serialize this kind of data you get this beautiful exception:

Converting anonymous type to a string also caused exception. But there is also JavaScriptSerializer:

Now using getter,...

One way object binding in JS

This is something I've been putting together this weekend. Due to the fact, that ASP.NET is quite reluctant to get an array of results, I've devised an alternative way of sending data to the server via Web.API. There are already several large frameworks that handle data-binding like Knockout and AngularJS, but these are rather heavy...

InverseProperty records not being savedin the database

In the code-first approach you can easily save object across multiple tables. This is great. However, today I tried saving an object with a set of other records:

In my controller I had simply:

However, the Items where not actually saved in the database. I just changed IEnumerbale to List and it worked...

Publishing WCF Web Service on IIS

Today, I will show you how to to publish WCF Web Service on IIS. I assume your have a working version of your WCF on IIS Express and you want to "publish" it. Step 1 - Install IIS Go to: Control Panel Programs and Features Turn Windows Features On and Off There are 4 things...

Column '' in table '' is of a type that is invalid for use as a key column in an index.

I've tried to create a simple (unique) constraint across multiple columns:

However I was greeted by: Column 'Name' in table 'dbo.UserLocations' is of a type that is invalid for use as a key column in an index. This can be fixed by adding: [DataType("VARCHAR")] and [MaxLength(40)] on the string. The point is that MaxLength...

Footer from database in MVC ASP.NET

I've been struggling for a while to find a sensible way of getting the footer. Well... This is where partial views come useful. There are several ways to solve this problem. I've created a controller:

In the Shared folder I've added _FooterPartial.cshtml and in the layout this line:

It worked so awesome.