Welcome to MSDN Blogs Sign in | Join | Help

LitwareHR on SSDS - Part II - The data access layer

The heart of LitwareHR implementation on SSDS is in it's data access layer of course. In fact, we created two different, but functionally equivalent implementations: one runs against SQL (LitwareHR's original implementation) and a second stack that runs against SSDS. Of course they are mutually exclusive and all layers above the DataModel cannot tell the difference.

 

image

 

As illustrated in the diagram above, the key class is Repository<T>, which among other things encapsulates all access to SSDS, translates T's into SSDS's Flexible Entities and in general provides a higher level of abstraction on top of SSDS artifacts. For example, Repository deals with tenants, which are then mapped into Authorities & Containers by a provider. The default implementation of this simply does a 1:1 mapping between Tenants and Containers, being Authorities fixed (as specified in configuration), but because it is using a provider model, you can supply a more sophisticated implementation.

T allows us to use typed objects that represent LitwareHR entities: Resumes, Positions, etc. so a hypothetical LitwareHR developer can write things similar to this:

public class Position : ExtensibleEntity
{
    public string Code {set;get;}
    public string Location {set; get;}
}
Position p = new Position { Id = Guid.NewGuid(), Code = "Code_1", Location = "Location_1", };

p.Fields.Add( "YearsOfExperience", 15 );
 

In LitwareHR all entities derive from ExtensibleEntity which is just a simple helper base class that provides some useful fields such as: Id, a collection of fields, etc.

In the example above, Id comes from ExtensibleEntity, Code and Location are defined at design time by the developer and "YearsOfExperience" might be a field that a particular tenant is adding to this position. Because it is a tenant specific field, it is defined at runtime.

Behind the scenes the Position entity will be translated into a SSDS flexible entity. Id, and Kind are intrinsic properties in SSDS and are automatically mapped into the Position.Id and typeof(Position).ToString(). The rest is mapped to flexible properties.

All those details are of course handled by Repository<T>. Its interface is straight forward and looks like the one below, which is self-explanatory.

Insert( T );

T GetById( id );

IEnumerable<T> ListAll();

IEnumerable<T> Search( string query );

Delete( id );

Update( T );

So a complete snippet (taken from one of our tests) looks like this:

 

image

Published Wednesday, March 19, 2008 11:05 AM by eugeniop

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# New and Notable 228

SOA/Service Bus/Design Patterns/SaaS Ayende - NServiceBus Review Ayende - NServiceBus Distributor Review

Sunday, March 23, 2008 11:49 PM by Sam Gentile

# Persister dans les nuages pour les éditeurs de logiciels

Dans ce post, Eugenio d&#233;crit comment int&#233;grer une couche de persistance dans les nuages (SQL

Wednesday, April 09, 2008 3:15 AM by Cloud Computing @ Microsoft France

# You liked LitwareHR v1, You loved LitwareHR v2, You are going to die for LitwareHR 'cloud storage' edition :)

More seriously... Eugenio just announced and released on Codeplex the latest drop of LitwareHR. Although

Tuesday, May 06, 2008 3:37 PM by Gianpaolo's blog

# LitwareHR Sample Application May 2008 Just Released

Microsoft Architecture Strategy Team has just shipped a new version of their LitwareHR Sample Application

Tuesday, May 06, 2008 8:21 PM by Pablo Damiani: <br /><b>Lito's Blog</b>

# SQL Server Data Services and LitwareHR

As many of you know, Microsoft has been working on a new version of LitwareHR that uses SQL Server Data

Monday, June 16, 2008 8:27 AM by Murray Gordon's Blog

# SQL Server Data Services en LitwareHR

Zoals een aantal van jullie wellicht weten is Microsoft bezig geweest met een nieuwe versie van LitwareHR

Wednesday, June 18, 2008 2:21 AM by ISV blog-voer

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker