Topic: ORM

Fluently NHibernate

logo

Fluent NHibernate is an extension of the widely used and very popular NHibernate framework for Microsoft .NET. It is an open source framework that sits on top of the NHibernate layer and utilises all the core NHibernate methods. This framework provides an alternative to the standard XML based mappings (.hbm xml files) of NHibernate. It lets you define the NHibernate mappings in strongly typed and concise C# code.  For those who are new to NHibernate, here is more information.

Continue reading »

LINQ to My Domain

Design SurfaceI've begun my foray into the world of LINQ, and in my investigation I've seen a lot of work based on the LINQ to SQL "design surface" available in Visual Studio 2008. It's a neat tool. I point it to my database, drag some tables over, and it infers my domain structure and relationships from the databases fields and keys. That's all well and good for a simple domain model that is directly related to the database schema. I could see using this for a quick prototype, or a really small application. I see three files created by the designer:

MyClasses.dbml - This looks like any ORM frameworks mapping file. It associates classes with tables, maps fields to object properties, and defines relationships.

 
<table border="0"></table>
 

MyClasses.dbml.layout - This looks to be specific to the layout of the design surface and appears to serve no purpose outside of this design.

MyClasses.designer.cs - This is the beast that I'm looking to replace. It contains the class definitions and attribute based mappings to bring my database schema into my application, and ready it for use by LINQ.

So this leaves me with a couple questions. One, why are attributes used to specify mappings? Can this be done strictly via XML? More importantly two, can I use my own domain model, and if so how do I map it to the database?

My goal would be to design a layered system, separating the underlying data store from the repositories required to push and pull my domain objects from these data stores. This would allow in memory implementations of the data store, and would make unit testing (and developing) a whole lot easier. I will be digging into this in the coming days and will report back soon. Stay tuned!

Topics: , ,

Launch: Pathfinder Newsletter

    Get a monthly update on best practices for delivering successful software.

    Subscribe via email


    Subscribe via RSS      RSS icon

Topics

Search

WordPress

Comments about this site: info@pathf.com