Posts tagged with: data-access

The quest to generate the perfect repository – Griffin DAL Generator

The data layer is something really important in an application. If it’s incorrectly created it will behave like a virus and infect the entire business layer making it a lot harder to build and maintain the application. Unfortunately the symptoms will not appear until the project have been built for some time. In this article I’ll present my attempt to a cure.

Continue Reading


Sample repository using Griffin.Framework

Here is small sample repository using Griffin.Framework

using Griffin.Container;
using Griffin.Data.Mapper;
using OneTrueError.GlobalCore.Invitations;
using OneTrueError.GlobalCore.Invitations.Data;

namespace OneTrueError.GlobalCore.SqlServer
{
    [Component]
    internal class InvitationRepository : IInvitationRepository
    {
        private readonly GlobalUnitOfWork _unitOfWork;

        public InvitationRepository(GlobalUnitOfWork unitOfWork)
        {
            _unitOfWork = unitOfWork;
        }

        public Invitation FindByEmail(string email)
        {
            return _unitOfWork.FirstOrDefault<Invitation>(new {EmailToInvitedUser = email});
        }

        public void Create(Invitation invitation)
        {
            _unitOfWork.Insert(invitation);
        }

        public void Update(Invitation invitation)
        {
            _unitOfWork.Update(invitation);
        }
    }
}

As you might have noticed I’m using one Assembly/DLL per SQL engine that we support. It’s not required for Griffin.Framework, but we are using plain ADO.NET for some DB operations and Griffin.Framework for others. Thus having one DLL per SQL engine allows us to write optimized queries without compromises.

In v2 of OneTrueError we are using two different databases. One for global activities like billing and customer accounts and then one customer specific DB for each customer. The reason is that we’ve had customers which gets several GB of error reports each month. Thus to make sure that the DB is responsive for all other customers (even when we are lacking a few efficient indexes) we’ve taken this approach.

When OneTrueError is started we simply use Assembly.Load together with a configuration setting in <appConfig> to be able to load the correct DLLs.





Introducing the data mapper in Griffin.Framework

As you might know I’m running a .NET exception service called OneTrueError. When I moved from a NoSQL db to SQL Azure I had to be able to work with the database in some way. I’m not using OR/Ms any more. They might significantly reduce the bootstrapping, but in the long run they always tend to make you struggle as the application grow. To me, ORMs is a bit like ASP.NET WebForms, but for data. i.e. it tries to make something what it isn’t. I therefore wanted something that did not take away the control from me nor hide the underlying layer. I still want to work with my domain entities though.

Continue Reading




ADO.NET, the right way

ADO.NET is actually quite powerful if you use it correctly. This post will teach you everything from making your ADO.NET code driver independent to how to implement the repository pattern and unit of work. This is the follow up post of my “Datalayer, the right way” post. The purpose is to demonstrate that ADO.NET can be used as an alternative to OR/Ms.

Continue Reading


Pages:12