Monday, 17 August 2009

Hotfix breaks live code

I have spent near enough all of today trying to fix a system that was broken by the automatic application of a Microsoft hotfix, specifically KB958484 Application Compatibility Update.

The first that I knew of any issue was when this morning discovered that one of our live sites had stopped working around 3am Sunday morning.  A little digging turned up that a windows update had been applied at this time, KB958484.

This gem of a hotfix changed the behaviour of the XmlSerializer so that where as before the hotfix if a class had a read only property the serializer just ignored the property, now the serializer threw an exception saying Unable to generate a temporary class (result=1). error CS0200: Property or indexer 'Person.Id' cannot be assign to -- it is read only

A bit of googling showed that I was not the only person experiencing problems in relation to this but a lot of the solutions weren’t very enlightening many mentioning that you needed to  use *Specified, and googling that didn’t turn up anything immediately apparent.

What it comes down to is using the attributes specifically related to Xml serialization like [XmlElement], now since the properties that were being complained about were public read only i.e. couldn’t be used for deserialization simply adding the attribute [XmlIgnore] resolved the issue.

Wednesday, 12 August 2009

Asp.Net Dynamic Data & Column ordering

As I've mentioned I'm just getting started with dynamic data and uncovering various things that I need to overcome or work around.

The first actual dynamic data issue, rather than linq-to-sql, was limiting the fields that were displayed so I created my class with a MetadataType attribute and I only got the columns that I want to display.

The next challenge was changing the name of a column, again this was easy all I needed in the meta data class was another attribute DisplayName and I could set the name of the column.

The final challenge I faced was needing to reorder the columns since I needed the fields to appear in a different order. So I googled for an attribute I could use to do this and found...nothing.

Out of the box dynamic data, in its current form, does not support re-ordering of columns. To me this seemed such a fundamental thing I was surprised that I couldn't do it.

So I googled some more to see if there were any solutions, custom code, extensions etc that I could find to provide the functionality.

The futures site popped up immediately and that has this functionality plus so much more, only issue is that I wasn't comfortable deploying the futures code for a production system.

So I carried on searching and thats when I found Dynamic Data Columns Ordering, an entry on the MSDN code gallery that contained code that you needed to add to your project and changes to make to existing files and then you just added a ColumnOrder attribute to the meta data and the column appears in the right order.


Sunday, 9 August 2009

Asp.Net Dynamic Data - first glance

So this last week when I've actually managed to get time to do development I've been working with Asp.Net dynamic data using Linq-to-Sql for data access.

My first impressions were quite good, create a model, provide the data context set the scaffolding to true and there you have an application. It all seems very easy, but then as with most things you try and do something that it doesn't really want to do and things become difficult.

As I've mentioned before some of the difficulties are related to Linq-to-Sql not doing what its supposed to but some of it is related to dynamic data.

Much like what I see as failings with Linq-to-Sql dynamic data seems to offer the ability to create UI with no or very little custom coding suggesting that if you want to change the standard behaviour you simply need to provide an attribute and you can change the way that the 'application' is generated.

Unfortunately this isn't the case, there are some attributes you can use such as [DisplayName] but at present these are few and far between.

As I get deeper into dynamic data I'm going to post what I've found, what you can do and what you can't.

Wednesday, 5 August 2009

Linq-to-Sql multiple views of the same data

In my previous post I mentioned the problems I have been having with Linq-to-Sql so I thought I'd elaborate on my difficulties.

Before now I hadn't used Linq-to-Sql but had seen demo's, web casts, etc that made it seem all so easy so I started work with high hopes. I set about adding a linq-to-sql file to the solution opened up the server explorer and added a table, all went well, but it was about to all go down hill rapidly.

Up to now I've done the majority of data access using stored procedure and was used to getting data from a table in any shape I wanted. My first problem with Linq-to-Sql was that I wished to have different views of the data in a single table and thought I should easily be able to define these views but this functionality simply is not available.

Now in linq's defence I don't remember it saying is should allow this type of functionality but as I said I had high hopes, I did find I could drag as many instances of single table into the model (got warning messages when I built but no other apparent problems) and I could then remove fields add properties etc but it felt wrong.

So for now this is what I've done, don't know if its the best or only way but will do for now.

Tuesday, 4 August 2009

Asp.Net Dynamic Data & Linq-to-Sql

Over the last few days I have been, when possible, trying to get to grips with Asp.Net Dynamic Data and Linq-to-Sql.

My first impression - its not what I expected.

It seems to be more difficult than it should be to be able to define the O/R mapping not to mention the little issue of the autogenerated datacontext disappearing if you extend the partial class and happen to name the class file the same as the .dbml file. Only turned on to the problem by a post on stackoverflow.

As I get more to grips with dynamic data I'll post more, for now I'm tending to pull my hair out trying to get it to do what should be simple

Monday, 3 August 2009

The first post

This is the first post on my blog.

My intention is to use this as a bit of a memory dump for me and along the way I may find some interesting things to talk about and would love for people to comment on what I've blogged, as I find you learn more through discussions rather than lectures.

The title? well thats what I do and all the cool names had already gone ;)

I'm currently working with Asp.Net technologies (webforms, MVC, dynamic data) and my next few posts will most likely cover them but I have been toying with going back to the beginning and doing a deep dive on web as a platform to refresh my memory.

Most of my posts will be about technology but I may digress now and then.

I can't promise I'll blog all the time but hopefully what I do blog will be interesting.