Sharp Architecture

S#arp Architecture (link). Github code repositories (link).

Official repository (link). Discussion group (link).

Installation:

    1. Download complete source code from the net. GitHub link to a repository did not work for me but the code is available in a zip file. Get SharpArchitecture_1_6_FullSourceAndTemplates.zip (or newer).
    2. Download the latest NAnt and replace the NAnt bin in the S#arp Architecture archive.
    3. Open the SharpArch.sln with Visual Studio 2010. Convert the solution file to .NET 4. Convert the projects' target framework to 4.0. Replace a few references to System.Web.Abstractions, System.Web.Routing to version 4.0. Add reference to System.ServiceModel.Activation. Remove reference to Iesi.Collections.Generic.
    4. Fix unit tests. NHibernateSessionTests exception type changed to FluentNHibernate.Cfg.FluentConfigurationException. Set SQLite.Net reference to CopyLocal=True.
    5. Set SharpArch.build for NAnt to use Framework 4.0 ("net-4.0"). Run the go.bat to generate CommonAssemblyInfo.cs
    6. Update references to NHibernate and Fluent to newer versions (if you want).
    7. Unit tests fail so, to ILmerge the assemblies, remove test build task in NAnt build script.
    8. Remove reference to NHibernate.Validator as it has been included in the main NHibernate assembly, as of version 3.
    9. run ClicktoBuildAndMerge.bat

Some common conventions:

    • Domain objects inherit from Entity or EntityWithTypedId if the Id is not int.
    • IRepositories inherit from INHibernateRepositoryWithTypedId if the Id is not int.

For multiple database connections see FAQ page.

Unit Testing with S#arp Architecture

There are two types of tests supported by the framework:

    1. tests with in-memory SQLite database, and
    2. tests with development database.

For in-memory db:

    • Add hibernate.cfg.xml for SQLite. Set it to copy to output directory.
    • Add the following to App.config:
      • <appSettings>
      • <!-- Accepts a comma delimited list of assembly names containing mapping artifacts; the ".dll" is optional -->
      • <add key="nhibernate.mapping.assembly" value="My.Library.Namespace" />
      • </appSettings>
    • Inherit test classes from RepositoryTestsBase.

Implement LoadTestData, where you can use repository methods to populate the database. When adding objects through a repository in LoadTestData, use FlushSessionandEvict(entity) to remove entity from the session cache so it is fetched from the (in-memory) db later, during the test.

Reference: (link)

Telerik

The best practices for integrating with Telerik grids (link).