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

2 Answers 2


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.

  • I am assuming that we could deploy the DAL as a custom farm solution to negate the need to manually update the GAC? Jan 20, 2011 at 13:10
  • Certainly so. Especially in multi-server environment. Jan 20, 2011 at 13:17
  • 1
    And pay great attention to concurrency issues in your DAL. Jan 20, 2011 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.

  • 3
    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. Jan 20, 2011 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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