Home > Uncategorized > ASP.NET 4 Breaking Changes #2: LinqToSQL char becomes string

ASP.NET 4 Breaking Changes #2: LinqToSQL char becomes string

If you are using LinqToSql instead of Entity Framework, you will notice (read compilation errors) that there are come about when you use VS2010 to regenerate the DBML file.

One of these is the fact that previously varchar(1) maps to char, but now it maps to string with a validation check for length > 1.

This will definitely cause errors during compilation especially when you have been using char comparison.

There are 2 ways to resolve this

1. Change the db from varchar(1) to char(1), this will render the dbml correctly as char 1 (Preferred method)

2. Change your code to handle this. but since this is now a string, you will have to make quite a fair bit of changes to ensure you do not put in more than 1 character inside this string. there’s also performance issues since char is always faster in comparison as compared to a string type

Categories: Uncategorized
  1. adminboy
    June 1, 2010 at 5:27 am

    any demo for nexsus script

    • kwanann
      June 2, 2010 at 10:01 pm

      sorry you mean the nexus app inside codeplex?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: