The DaxMindMapper Reloaded

Darrell Russell. A Software Contractor with over 10 years development experience. He is an experienced Microsoft .NET software developer specialising in C#, VB.NET, SQL Server Databases, ASP/ASP.NET web sites, XML, Web Services, WinForms, WCF and WFF development and consultancy work on a freelance basis. Based in the South West of the UK (Tetbury, Gloucestershire) and available to do work within South Wales, the M4 corridor, Gloucestershire, Dorset, Oxfordshire, Wiltshire and Somerset including Bath, Bristol, Swindon, Cheltenham, Gloucester and Salisbury. At the moment he is particulary interested in Agile Software development methodologies including Test Driven Development (TDD).

July 29, 2009

SQL Server 2005 Northwind Example Database

Filed under: SQL Server — Dax++ @ 12:12 pm

Looking at the S#arp Architecture for a new project I’m working on.

The example it supplies requires the Northwind database. Hey no problem I think .. it comes with SQL Server so shouldnt be an issue. First problem .. Microsoft no longer install this example database with their later SQL Server versions (actually this no bad thing for a whole bunch of reasons so I’m not angry at this point). However they then go onto make it rather difficult to actually recreate this standard example database.

Googling for “northwind database for sql 2005″ will come up with links to the old Microsoft download area, which then directs you to codeplex, which then offers you a large download for all of the old example databases that, unfortunately, does not actually include the bl**dy Northwind database.

Finally found this link .. looks like the way to go. I’ll try out the SQL script install and see how it goes.

July 8, 2009

Structs in C#

Filed under: Uncategorized — Dax++ @ 2:49 pm

Struct Examples and Tricks in C# - actually worthwhile reading.

I’d known that structs can be used to group some related items together (to aid understanding, reduce bugs etc) and I knew that they can be an aid for performance (less of an overhead compared to objects). But I didn’t really know why .. this article is a pretty clear introduction to the advantages of structs.

July 6, 2009

NHibernate, Views and Formula columns

Filed under: .Net — Dax++ @ 9:33 am

If you have an object type mapped to table1 and you need a piece of info from a related object type (thats mapped to a table2) then you can use a view (rather than a table) to make this attribute available in object type1. However this can cause issues with updates. So instead of a view you can use a computed column within object type 1 to gather the related data from the other table. This computed column uses the formula attribute within the nhibernate XML mapping file for object type 1.

Example

Object of type 1 requires a value from a related object of type 2. in this example the data type is a string and the relationship between the two objects is a one to one (so no issues with non existant records or multiple instances). This relation is actually already mapped but uses lazy loading becuase of the size of type 2 class (we don’t want to load the other type becuase it takes too long). However we still require this one string from the type 2 class in certain circumstances but dont want the performance hit of loading type 2.

We could use a view rather than the table within the NHibernate XML mapping file for type 1 but NHibernate will break if we need to perform an update - even if we are not updating this extra column (we do want to perform an update and we don’t need to update the string but the update = “false” has no effect).

So instead, within the object/table1 mapping file, add a new property to inform NHibernate of this new attribute within object type1. Please note the use of qualifiers within the SQL as NHibernate uses alias’s when it emits SQL to the datastore and that SQL will break if you don’t follow the syntax below exactly.

<property name="Name" type="String" formula="(SELECT <tableName2>.<columnName> FROM <tableName2> WHERE tableName2.<primaryKey> = <foreignKey>)" update="false" insert="false"/>

Powered by WordPress