Click here to Skip to main content
Click here to Skip to main content
Articles » Database » Database » Data Access » Downloads
 
Add your own
alternative version

Implementing Repository Pattern With Entity Framework

, 2 Nov 2012
Implement Repository Pattern in data access layer with Entity Framework 4.0 and Below version( Working with ObjectContext and EntityObject )
RepositoryProjectPOC_Revised_-noexe.zip
RepositoryProjectSample
RepositoryProjectSample
DataModel.edmx
Helper
Implementations
Entity Framework
Interfaces
obj
x86
Debug
edmxResourcesToEmbed
DataModel.csdl
DataModel.msl
DataModel.ssdl
Properties
RepositoryProjectSample.suo
RepositoryProjectPOC_Revised_.zip
bin
Debug
Release
DataModel.edmx
DesignTimeResolveAssemblyReferencesInput.cache
DataModel.csdl
DataModel.msl
DataModel.ssdl
RepositoryProjectSample.csprojResolveAssemblyReference.cache
RepositoryProjectSample.exe
RepositoryProjectSample.pdb
TempPE
DataModel.Designer.cs.dll
RepositoryProjectSample.suo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;
using System.Data.Common;
using System.Collections.ObjectModel;
using System.Linq.Expressions;

namespace RepositoryProjectSample.Interfaces
{
    /// <summary>
    /// Repository Interface defines the base
    /// functionality required by all Repositories.
    /// </summary>
    /// <typeparam name="T">
    /// The entity type that requires a Repository.
    /// </typeparam>
    public interface IRepository<E>
    {
        string KeyProperty { get; set; }

        void Add(E entity);
        void AddOrAttach(E entity);
        void DeleteRelatedEntries(E entity);
        void DeleteRelatedEntries
        (E entity, ObservableCollection<string> keyListOfIgnoreEntites);
        void Delete(E entity);

        ObjectQuery<E> DoQuery();
        ObjectQuery<E> DoQuery(ISpecification<E> where);
        ObjectQuery<E> DoQuery(int maximumRows, int startRowIndex);
        ObjectQuery<E> DoQuery(Expression<Func<E, object>> sortExpression);
        ObjectQuery<E> DoQuery(Expression<Func<E, object>> sortExpression,
                    int maximumRows, int startRowIndex);

        IList<E> SelectAll(string entitySetName);
        IList<E> SelectAll();
        IList<E> SelectAll(string entitySetName, ISpecification<E> where);
        IList<E> SelectAll(ISpecification<E> where);
        IList<E> SelectAll(int maximumRows, int startRowIndex);
        IList<E> SelectAll(Expression<Func<E, object>> sortExpression);
        IList<E> SelectAll(Expression<Func<E, object>> sortExpression,
                    int maximumRows, int startRowIndex);

        E SelectByKey(string Key);

        bool TrySameValueExist(string fieldName, object fieldValue, string key);
        bool TryEntity(ISpecification<E> selectSpec);

        int GetCount();
        int GetCount(ISpecification<E> selectSpec);
    }
}

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

You may also be interested in...

About the Author

Morshed Anwar
Team Leader Adaptive Enterprise Limited (www.ael-bd.com)
Bangladesh Bangladesh
No Biography provided

| Advertise | Privacy | Mobile
Web03 | 2.8.140902.1 | Last Updated 2 Nov 2012
Article Copyright 2009 by Morshed Anwar
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid