Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

In memory data access, a methodology to simplify agile development

, 25 Nov 2008
An article on architecting application layers to separate concerns and, particularly, data access.
InMemoryDal_src.zip
InMemoryDal
InMemoryDal.BusinessLogic
bin
Debug
InMemoryDal.BusinessLogic.dll
InMemoryDal.Entities.dll
InMemoryDal.Helpers.dll
InMemoryDal.InMemoryData.dll
InMemoryDal.Interfaces.dll
NLog.dll
Properties
InMemoryDal.Entities
bin
Debug
InMemoryDal.Entities.dll
ClassDiagram1.cd
Entities.cd
Properties
InMemoryDal.Helpers
bin
Debug
InMemoryDal.Entities.dll
InMemoryDal.Helpers.dll
InMemoryDal.InMemoryData.dll
InMemoryDal.Interfaces.dll
Properties
InMemoryDal.InMemoryData
bin
Debug
InMemoryDal.Entities.dll
InMemoryDal.InMemoryData.dll
InMemoryDal.Interfaces.dll
Properties
InMemoryDal.Interfaces
bin
Debug
InMemoryDal.Entities.dll
InMemoryDal.Interfaces.dll
Interfaces.cd
Properties
InMemoryDal.Tests
bin
Debug
InMemoryDal.BusinessLogic.dll
InMemoryDal.BusinessLogic.pdb
InMemoryDal.Entities.dll
InMemoryDal.Entities.pdb
InMemoryDal.Helpers.dll
InMemoryDal.Helpers.pdb
InMemoryDal.InMemoryData.dll
InMemoryDal.InMemoryData.pdb
InMemoryDal.Interfaces.dll
InMemoryDal.Interfaces.pdb
InMemoryDal.Tests.dll
InMemoryDal.Tests.pdb
NLog.dll
Properties
InMemoryDal.vsmdi
InMemoryDal1.vsmdi
InMemoryDal2.vsmdi
LocalTestRun.testrunconfig
TestResults

using System;
using System.Collections.Generic;
using System.Text;
using InMemoryDal.Interfaces;
using InMemoryDal.Entities;

namespace InMemoryDal.InMemoryData
{
    [Serializable]
    public sealed class OrderItemInMemoryDAL : IOrderItemDAL
    {
        internal List<OrderItem> OrderItemList;

        static readonly OrderItemInMemoryDAL _istance = new OrderItemInMemoryDAL();

        private OrderItemInMemoryDAL()
        {
            OrderItemList = new List<OrderItem>();
        }

        internal static OrderItemInMemoryDAL Istance
        {
            get { return _istance; }
        }

        #region IOrderItemDAL Members

        public List<OrderItem> Search(Guid id, Guid idProduct, Guid idContainingOrder, Int32 quantity, OrderItemDataAdapterHandler orderItemDataAdapter)
        {
            List<OrderItem> lis = OrderItemList;

            if (id != Guid.Empty) { lis = lis.FindAll(delegate(OrderItem entity) { return entity.Id == id; }); }

            if (idProduct != Guid.Empty) { lis = lis.FindAll(delegate(OrderItem entity) { return entity.Product.Id == id; }); }

            if (idContainingOrder != Guid.Empty) { lis = lis.FindAll(delegate(OrderItem entity) { return entity.ContainingOrder.Id == id; }); }

            if (quantity != 0) { lis = lis.FindAll(delegate(OrderItem entity) { return entity.Quantity == quantity; }); }



            return lis;
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Software architect. At present working on C# development, with mainly Asp.net Ajax and MVC user inteface. Particularly interested in OOP, test driven, agile development.

| Advertise | Privacy | Mobile
Web02 | 2.8.140922.1 | Last Updated 25 Nov 2008
Article Copyright 2008 by Giorgio Bozio
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid