SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering what your thoughts were on a shared data access layer in a SharePoint farm. I am well aware of the implications of accessing the SharePoint content databases directly - I am referring to a custom application database that is utilised within client SharePoint sites.

We implement this as a class library deployed to the GAC which is mainly utilised in Web parts.

In this scenario the code is thoroughly reviewed given that it will have full trust across the Web server.

As we move toward SharePoint 2010 I am interested to know whether this is considered good practice or whether there is an alternate approach that we are missing. If you are using a custom application DB, do you connect directly from your SharePoint solution or via a DAL?

Cheers in advance. Ben

share|improve this question
up vote 3 down vote accepted

It is usually a good idea to use a DAL in terms of code reuse and quality of code (hint: let your best developers code the reusable components).

You could also consider using BCS/BDC and integrate through that. Performance wise using the GAC is a good thing. When using bin its a good practice to run with CAS set with as minimal privileges as possible, and if you have multiple teams delivering code for the solution bin deployment should be considered in favour of GAC.

share|improve this answer
I am assuming that we could deploy the DAL as a custom farm solution to negate the need to manually update the GAC? – Benjamin J Athawes Jan 20 '11 at 13:10
Certainly so. Especially in multi-server environment. – Alexey Krasheninnikov Jan 20 '11 at 13:17
And pay great attention to concurrency issues in your DAL. – Alexey Krasheninnikov Jan 20 '11 at 13:19

I'm currently in the process of writing a DAL class library to access a custom application DB via SharePoint.

As an interesting side note, in our case the DAL actually accesses a web service, which in turn accesses the DB. (The main reason for this being that our current DBMS only has a 32bit data provider, whereas our SP is 64bit...)

One obvious benefit of using the DAL class library as opposed to calling the web service in each web part etc, is if at some point we wish to access the DB via an alternative method, this will only change in the DAL -- not in every webpart.

share|improve this answer
In my understanding, this is a good approach for SharePoint 2007/3.0 but the best practice for 2010 would be a custom ServiceApplication which would sport the benefits of scalability and unified support practice. – Alexey Krasheninnikov Jan 20 '11 at 15:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.