Retrieving data from both nHibernate and r/o AD

12 views
Skip to first unread message

CameronH

unread,
Feb 10, 2009, 11:44:32 AM2/10/09
to S#arp Architecture
Hi all,

I've only just recently started using S#harp Architecture and want to
have a domain entity object that
has data provided by two different sources, read/write by a SQL server
via nHibernate, read-only from
an Active Directory LDAP server.

I have a Person entity that has a number of public properties
(LoginName, FullName, HomeNumber,
WorkNumber, MobileNumber). The only data to be stored in the database
is the PersonID and the LoginName,
and the rest is stored in Active Directory, but should be accessible
as read only properties that
are filled with data from LDAP (depending on the LoginName).

To attempt this, I set up Core.Person class (Entity) with the public
properties, then I have the
Data.PersonRepository class (Core.IPersonRepository,
Repository<Person>) which contains methods
for extracting the properties from LDAP using DirectoryServices,
provided a string login name. I put a public
IPersonRepository typed property in the Core.Person class, and
Core.Person uses it to get the LDAP data
from a repository object. There is a Data.NHibernateMappings.PersonMap
class that does the FluentNHibernate
mappings. This all works as expected, except that I manually have to
set the PersonRepository property every
time I create or use a Core.Person object, so that it knows where to
get the LDAP data.

Firstly, is this the correct way to do things? Secondly, if so, how
should I go about getting the person repository
object to automatically wire up to a Data.PersonRepository object? I
can't use a constructor parameter, because there
needs to be a parameterless constructor. It has been suggested to me
to use Castle Windsor, but I'm new to the
entire whole set of non-default .NET APIs used in S#harp Architecture
and wouldn't know where to start.

Thanks,
Cameron
Reply all
Reply to author
Forward
0 new messages