There are, of course, about a million ways to implement a data access layer in any N-tier application. Some are better than others and most people have their own favorite practices and patterns. But is there a practice or pattern that anyone can think of that is somehow specifically well suited for use in SoapBox Core or SoapBox Core addins/parts? Maybe there is some way to leverages the power of MEF or some other attribute of the SoapBox Core machinery to create a particularly robust data access layer.

asked 19 Oct '10, 22:23

KarlB's gravatar image

accept rate: 0%

edited 21 Oct '10, 20:22

Scott%20Whitlock's gravatar image

Scott Whitlock ♦♦

SoapBox Core is, by definition, an MVVM framework. In fact, it doesn't ship with any implementation of a Model, so it's really a View-ViewModel framework. (In the case of SoapBox Snap, the Data Access Layer is provided by SoapBox Protocol). Your persistence layer is usually either encapsulated within your Model (if you use the ActiveRecord pattern) or is a service only known to your Model (if you use the Repository or Unit of Work pattern).

Given that SoapBox Core is Model-Agnostic, I'm tempted to say that a DAL doesn't belong there. That doesn't mean there couldn't be a separate SoapBox.Model framework, but I really think you should be able to completely mix and match SoapBox Core with any Model.

To answer your question in the title, from experience, I suggest combining the following:

Your repository looks like this:

public interface IRepository<T>
    void Save(T entity);
    void Delete(T entity);
    T Get(object key);
    IQueryable<T> AllEntities();

Your model layer logic can look like this:

using(var uow = UnitOfWork.Begin())
    var widgetRepository = uow.GetRepository<Widget>();
    var activeWidgets = (from w in widgetRepository.AllEntities().ThatAreActive
                         select w)

answered 21 Oct '10, 13:00

Scott%20Whitlock's gravatar image

Scott Whitlock ♦♦
accept rate: 50%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 19 Oct '10, 22:23

Seen: 2,715 times

Last updated: 21 Oct '10, 20:22

powered by OSQA