Mobile post test
Mobi test
For awhile I’ve been trying to integrate Csla and nHibernate. Being new to nHibernate that is where my difficulties lay. However, recentlly I’ve come accross an excellent tutorial by Gabriel Schenker. You can find it here.
It was not too difficult to incorporate Csla into Gabriel’s excellent example.

You can download the source here. Just create a new empty solution and add the three existing projects. The download includes a folder named sharedLibs, which has the referenced dlls for nHibernate and MySQL connector.
Not all Csla data portal methods are implemented only Fetch and Insert.
The Csla object was generated using Codesmith 2.6. You may want to convert the tests to nUnit tests. My example uses MySQL as the data store.
I don’t like my implementation 100%, but it works and is going to be my starting point for other projects. I would like to move the DTO into a separate project. But whenI try that I just can’t get nHibernate mapping to work. I get the dreaded “Unknown Entity” error and am not able to fix it.
Next up, a more complex Csla object, one with children then optimistic concurrency.
This is what the Fetch looks like
#region Data Access - Fetch
private void DataPortal_Fetch(SingleCriteria criteria)
{
IDALRepository repository = new DALRepository();
var data = repository.GetById(criteria.Value);
LoadProperty(IdProperty, data.Id);
LoadProperty(NameProperty, data.Name);
ValidationRules.CheckRules();
}
#endregion //Data Access - Fetch
This is what the Insert looks like
#region Data Access - Insert
protected override void DataPortal_Insert()
{
BudanArtLib.DAL.DTO.Item data = new BudanArtLib.DAL.DTO.Item();
//data.Id = ReadProperty(IdProperty);
data.Name = ReadProperty(NameProperty);
IDALRepository repository = new DALRepository();
repository.Add(data);
LoadProperty(IdProperty, data.Id);
}
#endregion //Data Access - Insert



You probably already know but Rush’s The Spirit of Radio was inspired by CFNY.
Soooo if you liked 102.1 in the 80s check out The Mars Bar on Whitby’s 94.9 The Rock. He’s on Thursday and Friday nights. Go Dave! You still play the only music worth listening to in Toronto.
Saw and heard the first Robin of the year yesterday morning. Saw one again this morning. Yeah! Spring. Heard a Blue Jay last week, but didn’t see it.