Technology with opinion

Thursday, November 19, 2009

Mapping Date & Time fields With NHibernate

Let's say you have an entity or POCO that you have mapped from NHibernate (or any ORM) and the database has separated out the Date & Time values into separate fields.  Your best best is to map these Date & Time fields into properties (DateTime for Date and TimeSpan for Time).  Then create a helper property in your POCO to add them together.  I'd like to add that I'm not a fan of separating these sorts of things in the database, but some people do this for some reason:

HBM:


POCO

In my case either of these could be null (yes another great idea) which means I had to handle the nullability however this illustrates at least in worse case scenerio what will happen.  Date & Time data types are available in SQL Server 2008 and work with NHibernate 2.1 with .Net 2.0 or above.

Monday, November 16, 2009

Associating Users & Logins in SQL Server after Database Restore

Often times when you restore a database in SQL Server from one server to the next the Logins will become disassociated with the User a specific database.  We ran into this today and another software engineer found a good script from a guy he knows:



Executing this script should find unassociated logins and reassociate them with the users in the current database

Friday, November 06, 2009

CI Done Simple with CruiseControl.Net + MSBuild

If you want to setup Continuous Integration the learning curve for automated builds can be moderate for some. CruiseControl.Net (CCNet) allows you to integrate with automated build technologies such as NAnt, MSBuild, etc.  The advantage of this is that you can specify the Visual Studio Solution so that MSBuild knows the references and source code to build.

This example assumes using TFS for source code control, which definitely isn't my favorite SCM tool but odds are if you want to keep it simple and you're not using NAnt then you're probably in a shop that uses TFS.