NHibernate and nvarchar(MAX)

November 27, 2007

Been using NHibernate on my most recent project and the team and I have spent a bit of time trying to figure out how to get around the fact that NHibernate generates all strings as nvarchar(255) by default. We’re also using Attributes for our NHibernate mappings (NHibernate.Mapping.Attributes). The solutions is actually quite simple.

private string _myString;

[Property(length = 4001)]
public string MyString
get { return _myString; }
set { _myString = value; }

Setting the length to anything over 4000 forces NHibernate to generate the DB schema with a DB type of nvarchar(MAX).

I’ve only tested this with the SQL 2005 dialect (Dialect.MsSql2005Dialect)

asp.net on Rails?

September 21, 2007

Came across this today: Subsonic It’ll build your entire DAL (Data Access Layer). So you end up with a typed object representation of your database. Really cool and could save lots of time. It also has Ruby on Rails like scaffolding built right in. I’m about to start using it and will post once I’ve had a chance to put it through its paces.  In the mean time, my praises go out to the Subsonic team for putting together what I think has been a long needed addition to .net.

If anyone has used this already, please let me know what your experience with it has been like.

ASP.Net: State and Country Dropdown lists

August 29, 2007

Thank god for the great Interweb! These two pages saved me a lot of time typing out the full controls for state and country dropdown lists. It’s as easy as copy and paste.

Country Dropdown:

State Dropdown:

And here is my version that includes the Canadian provinces and territories:

Read the rest of this entry »

ASP.Net 2.0 and AJAX 1.0

August 28, 2007

If you’ve been using the ASP.Net Ajax framework since it more or less came out and have tried to download and get the latest and greatest version of it running. You most likely ended up getting the following error message:

Parser Error Message: Could not load file or assembly ‘System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified.

Well, after reading many a forum and trial and error, I got it to all work again. To think all of this to get the damned MaskedEditExtender to work 🙂 Here are the steps, they’re simple and with any luck anyone with this problems reading this entry will have an easier time then I.

  1. Unsinstall the AjaxExtentions if you have it installed on your system. You’ll see this in the add/remove programs under “Microsoft ASP.NET 2.0 AJAX Extensions 1.0” or something very close to it.
  2. Download the new extension from here: http://asp.net/ajax/downloads/
  3. Install the extensions
  4. Download the AJAX Toolkit, you can find the link in the same place as mentioned above.
  5. Install them
  6. If you’re starting a project or website from scratch, you’re good to go now. If you already have a project that needs to be updated keep reading.
  7. In your project add a reference to System.Web.Extensions and System.Web.Extensions.Design
  8. Remove references to Microsoft.Web.Extensions and Microsoft.Web.Extensions.Design (if you have any)
  9. Remove references to AjaxControlToolkit (if you have it)
  10. Add a reference to AjaxControlToolkit (make sure you’re referencing the newly downloaded one)
  11. Go through your code and replace references to Microsoft.Web.Extensions with System.Web.Extensions
  12. Build and pray

If you still have issues, drop me a line, I might be able to help, but I’m not promising anything.

Good luck!