Click here to Skip to main content
Click here to Skip to main content
Articles » Database » Database » Data Access » Revisions
 

Implementing Repository Pattern With Entity Framework

, 10 Jun 2009
Rate this:
Please Sign up or sign in to vote.
Implement Repository Pattern in data access layer with Entity Framework
This is an old version of the currently published article.

Introduction

The Repository pattern is defined by Patterns of Enterprise Application Architecture as:   

Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects.

Repository provides an in-memory like collection interface for accessing domain objects. So as far as the consuming component is concerned, it uses the repository just like a collection when working with Domain objects. The repository then neatly abstracts the internal mechanics of how the Add / Remove calls to the repository translate to the actual data access calls to the data store. Objects can be added to and removed from the Repository, as they can from a simple collection of objects, and the mapping code encapsulated by the Repository will carry out the appropriate operations behind the scenes. Conceptually, a Repository encapsulates the set of objects persisted in a data store and the operations performed over them, providing a more object-oriented view of the persistence layer. Repository also supports the objective of achieving a clean separation and one-way dependency between the domain and data mapping layers.

So with the repository we get a nice abstraction that provides us with persistence ignorance and a nice separation of concerns where the responsibility of persisting domain objects is encapsulated by the Repository leaving the domain objects to deal entirely with the domain model and domain logic.

Using the Code

Here I use the Composite Repository pattern:

/// <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, C>
{
    DbTransaction BeginTransaction();
    void Add(E entity);
    void AddOrAttach(E entity);
    void DeleteRelatedEntries(E entity);
    void DeleteRelatedEntries
	(E entity, ObservableCollection<string> keyListOfIgnoreEntites);
    void Delete(E entity);
    int Save();
 
    ObjectQuery<E> DoQuery(string entitySetName);
    ObjectQuery<E> DoQuery();
    ObjectQuery<E> DoQuery(string entitySetName, ISpecification<E> where);
    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);
}

You can write your own Repository for each business object like RoleRepository, UserReporsitory, etc. Or you can implement this interface as a generic class of Repository something like this: 

public class Repository<E, C> : IRepository<E, C>, IDisposable
    where E : EntityObject
    where C : ObjectContext
{
    private readonly C _ctx;
 
    private string _KeyProperty = "ID";
 
    public string KeyProperty
    {
        get
        {
            return _KeyProperty;
        }
        set
        {
            _KeyProperty = value;
        }
    }
 
    public C Session
    {
        get { return _ctx; }
    }
 
    public Repository(C session)
    {
        _ctx = session;
    }
 
    #region IRepository<E,C> Members
 
    public int Save()
    {
        return _ctx.SaveChanges();
    }
    /// <summary>
    /// A generic method to return ALL the entities
    /// </summary>
    /// <param name=”entitySetName”>
    /// The EntitySet name of the entity in the model.
    /// </param>
    /// <typeparam name=”TEntity”>
    /// The Entity to load from the database.
    /// </typeparam>
    /// <returns>Returns a set of TEntity.</returns>
    public ObjectQuery<E> DoQuery(string entitySetName)
    {
        return _ctx.CreateQuery<E>("[" + entitySetName + "]");
    }
    /// <summary>
    /// A generic method to return ALL the entities
    /// </summary>
    /// <typeparam name=”TEntity”>
    /// The Entity to load from the database.
    /// </typeparam>
    /// <returns>Returns a set of TEntity.</returns>
    public ObjectQuery<E> DoQuery()
    {
        return _ctx.CreateQuery<E>("[" + typeof(E).Name + "]");
    }
 
    /// <summary>
    /// </summary>
    /// <param name=”entitySetName”>
    /// The EntitySet name of the entity in the model.
    /// </param>
    /// <typeparam name=”TEntity”>
    /// The Entity to load from the database.
    /// </typeparam>
    /// <returns>Returns a set of TEntity.</returns>
    public ObjectQuery<E> DoQuery(string entitySetName, ISpecification<E> where)
    {
        return
            (ObjectQuery<E>)_ctx.CreateQuery<E>("[" + entitySetName + "]")
            .Where(where.EvalPredicate);
    }

    /// <summary>
    /// </summary>
    /// <typeparam name=”TEntity”>
    /// The Entity to load from the database.
    /// </typeparam>
    /// <returns>Returns a set of TEntity.</returns>
    public ObjectQuery<E> DoQuery(ISpecification<E> where)
    {
        return
            (ObjectQuery<E>)_ctx.CreateQuery<E>("[" + typeof(E).Name + "]")
            .Where(where.EvalPredicate);
    }
    /// <summary>
    /// Query Entity with Paging 
    /// </summary>
    /// <param name="maximumRows">Max no of row to Fetch</param>
    /// <param name="startRowIndex">Start Index</param>
    /// <returns>Collection of Entities</returns>
    public ObjectQuery<E> DoQuery(int maximumRows, int startRowIndex)
    {
        return (ObjectQuery<E>)_ctx.CreateQuery<E>
	("[" + typeof(E).Name + "]").Skip<E>(startRowIndex).Take(maximumRows);
    }
    /// <summary>
    /// Query Entity in sorted Order
    /// </summary>
    /// <param name="sortExpression">Sort Expression/condition</param>
    /// <param name="ErrorCode">custom Error Message</param> 
    /// <returns>Collection of Entities</returns>
    public ObjectQuery<E> DoQuery(Expression<Func<E, object>> sortExpression)
    {
        if (null == sortExpression)
        {
            return ((IRepository<E, C>)this).DoQuery();
        }
        return (ObjectQuery<E>)((IRepository<E, C>)this).DoQuery().OrderBy
					<E, object>(sortExpression);
    }
    /// <summary>
    /// Query All Entity in sorted Order with Paging support
    /// </summary>
    /// <param name="sortExpression">Sort Expression/condition</param>
    /// <param name="maximumRows">Max no of row to Fetch</param>
    /// <param name="startRowIndex">Start Index</param>
    /// <returns>Collection Of entities</returns>
    public ObjectQuery<E> DoQuery(Expression<Func<E, object>> 
		sortExpression, int maximumRows, int startRowIndex)
    {
        if (sortExpression == null)
        {
            return ((IRepository<E, C>)this).DoQuery(maximumRows, startRowIndex);
        }
        return (ObjectQuery<E>)((IRepository<E, C>)this).DoQuery
		(sortExpression).Skip<E>(startRowIndex).Take(maximumRows);
    }
    /// <summary>
    /// A generic method to return ALL the entities
    /// </summary>
    /// <param name=”entitySetName”>
    /// The EntitySet name of the entity in the model.
    /// </param>
    /// <typeparam name=”TEntity”>
    /// The Entity to load from the database.
    /// </typeparam>
    /// <returns>Returns a set of TEntity.</returns>
    public IList<E> SelectAll(string entitySetName)
    {
        return DoQuery(entitySetName).ToList();
    }
    /// <summary>
    /// A generic method to return ALL the entities
    /// </summary>
    /// <typeparam name=”TEntity”>
    /// The Entity to load from the database.
    /// </typeparam>
    /// <returns>Returns a set of TEntity.</returns>
    public IList<E> SelectAll()
    {
        try
        {
            return DoQuery().ToList(); //_ctx.CreateQuery<E>
				("[" + typeof(E).Name + "]");
        }
        catch (Exception)
        {
            throw;
        }
    }
 
    /// <summary>
    /// A generic method to return ALL the entities
    /// </summary>
    /// <param name=”entitySetName”>
    /// The EntitySet name of the entity in the model.
    /// </param>
    /// <typeparam name=”TEntity”>
    /// The Entity to load from the database.
    /// </typeparam>
    /// <returns>Returns a set of TEntity.</returns>
    public IList<E> SelectAll(string entitySetName, ISpecification<E> where)
    {
        return DoQuery(entitySetName, where).ToList();
    }
 
    /// <summary>
    /// A generic method to return ALL the entities
    /// </summary>
    /// <typeparam name=”TEntity”>
    /// The Entity to load from the database.
    /// </typeparam>
    /// <returns>Returns a set of TEntity.</returns>
    public IList<E> SelectAll(ISpecification<E> where)
    {
        return DoQuery(where).ToList();
    }
    /// <summary>
    /// Select All Entity with Paging 
    /// </summary>
    /// <param name="maximumRows">Max no of row to Fetch</param>
    /// <param name="startRowIndex">Start Index</param>
    /// <returns>Collection of Entities</returns>
    public IList<E> SelectAll(int maximumRows, int startRowIndex)
    {
        return DoQuery(maximumRows, startRowIndex).ToList();
    }
    /// <summary>
    /// Select All Entity in sorted Order
    /// </summary>
    /// <param name="sortExpression">Sort Expression/condition</param>
    /// <param name="ErrorCode">custom Error Message</param> 
    /// <returns>Collection of Entities</returns>
    public IList<E> SelectAll(Expression<Func<E, object>> sortExpression)
    {
        if (null == sortExpression)
        {
            return DoQuery(sortExpression).ToList();
        }
        return DoQuery(sortExpression).ToList();
    }
    /// <summary>
    /// Select All Entity in sorted Order with Paging support
    /// </summary>
    /// <param name="sortExpression">Sort Expression/condition</param>
    /// <param name="maximumRows">Max no of row to Fetch</param>
    /// <param name="startRowIndex">Start Index</param>
    /// <returns>Collection Of entities</returns>
    public IList<E> SelectAll(Expression<Func<E, object>> 
		sortExpression, int maximumRows, int startRowIndex)
    {
        if (sortExpression == null)
        {
            return DoQuery(maximumRows, startRowIndex).ToList();
        }
        return DoQuery(sortExpression, maximumRows, startRowIndex).ToList();
    }
    /// <summary>
    /// Get Entity By Primary Key
    /// </summary>
    /// <typeparam name="E">Entity Type</typeparam>
    /// <param name="Key">Primary Key Value</param>
    /// <returns>return entity</returns>
    public E SelectByKey(string Key)
    {
        // First we define the parameter that we are going to use the clause. 
        var xParam = Expression.Parameter(typeof(E), typeof(E).Name);
        MemberExpression leftExpr = MemberExpression.Property(xParam, this._KeyProperty);
        Expression rightExpr = Expression.Constant(Key);
        BinaryExpression binaryExpr = MemberExpression.Equal(leftExpr, rightExpr);
        //Create Lambda Expression for the selection 
        Expression<Func<E, bool>> lambdaExpr = 
		Expression.Lambda<Func<E, bool>>(binaryExpr, 
		new ParameterExpression[] { xParam });
        //Searching ....
        IList<E> resultCollection = ((IRepository<E, C>)this).SelectAll
					(new Specification<E>(lambdaExpr));
        if (null != resultCollection && resultCollection.Count() > 0)
        {
            //return valid single result
            return resultCollection.First<E>();
        }//end if 
        return null;
    }
    /// <summary>
    /// Check if value of specific field is already exist
    /// </summary>
    /// <typeparam name="E"></typeparam>
    /// <param name="fieldName">name of the Field</param>
    /// <param name="fieldValue">Field value</param>
    /// <param name="key">Primary key value</param>
    /// <returns>True or False</returns>
    public bool TrySameValueExist(string fieldName, object fieldValue, string key)
    {
        // First we define the parameter that we are going to use the clause. 
        var xParam = Expression.Parameter(typeof(E), typeof(E).Name);
        MemberExpression leftExprFieldCheck = 
		MemberExpression.Property(xParam, fieldName);
        Expression rightExprFieldCheck = Expression.Constant(fieldValue);
        BinaryExpression binaryExprFieldCheck = 
		MemberExpression.Equal(leftExprFieldCheck, rightExprFieldCheck);
 
        MemberExpression leftExprKeyCheck = 
		MemberExpression.Property(xParam, this._KeyProperty);
        Expression rightExprKeyCheck = Expression.Constant(key);
        BinaryExpression binaryExprKeyCheck = 
		MemberExpression.NotEqual(leftExprKeyCheck, rightExprKeyCheck);
        BinaryExpression finalBinaryExpr = 
		Expression.And(binaryExprFieldCheck, binaryExprKeyCheck);
 
        //Create Lambda Expression for the selection 
        Expression<Func<E, bool>> lambdaExpr = 
		Expression.Lambda<Func<E, bool>>(finalBinaryExpr, 
		new ParameterExpression[] { xParam });
        //Searching ....            
        return ((IRepository<E, C>)this).TryEntity(new Specification<E>(lambdaExpr));
    }
    /// <summary>
    /// Check if Entities exist with Condition
    /// </summary>
    /// <param name="selectExpression">Selection Condition</param>
    /// <returns>True or False</returns>
    public bool TryEntity(ISpecification<E> selectSpec)
    {
        return _ctx.CreateQuery<E>("[" + typeof(E).Name + "]").Any<E>
					(selectSpec.EvalPredicate);
    }
    /// <summary>
    /// Get Count of all records
    /// </summary>
    /// <typeparam name="E"></typeparam>
    /// <returns>count of all records</returns>
    public int GetCount()
    {
        return _ctx.CreateQuery<E>("[" + typeof(E).Name + "]").Count();
    }
    /// <summary>
    /// Get count of selection
    /// </summary>
    /// <typeparam name="E">Selection Condition</typeparam>
    /// <returns>count of selection</returns>
    public int GetCount(ISpecification<E> selectSpec)
    {
        return _ctx.CreateQuery<E>("[" + typeof(E).Name + "]")
            .Where(selectSpec.EvalPredicate).Count();
    }
    /// <summary>
    /// Delete data from context
    /// </summary>
    /// <typeparam name="E"></typeparam>
    /// <param name="entity"></param>
    public void Delete(E entity)
    {
        _ctx.DeleteObject(entity);
    }
    /// <summary>
    /// Delete data from context
    /// </summary>
    /// <typeparam name="E"></typeparam>
    /// <param name="entity"></param>
    public void Delete(object entity)
    {
        _ctx.DeleteObject(entity);
    }
    /// <summary>
    /// Insert new data into context
    /// </summary>
    /// <typeparam name="E"></typeparam>
    /// <param name="entity"></param>
    public void Add(E entity)
    {
        _ctx.AddObject(entity.GetType().Name, entity);
    }
    /// <summary>
    /// Insert if new otherwise attach data into context
    /// </summary>
    /// <param name="entity"></param>
    public void AddOrAttach(E entity)
    {
        // Define an ObjectStateEntry and EntityKey for the current object.
        EntityKey key;
        object originalItem;
        // Get the detached object's entity key.
        if (entity.EntityKey == null)
        {
            // Get the entity key of the updated object.
            key = _ctx.CreateEntityKey(entity.GetType().Name, entity);
        }
        else
        {
            key = entity.EntityKey;
        }
        try
        {
            // Get the original item based on the entity key from the context
            // or from the database.
            if (_ctx.TryGetObjectByKey(key, out originalItem))
            {//accept the changed property
                if (originalItem is EntityObject &&
                    ((EntityObject)originalItem).EntityState != EntityState.Added)
                {
                    // Call the ApplyPropertyChanges method to apply changes
                    // from the updated item to the original version.
                    _ctx.ApplyPropertyChanges(
                        key.EntitySetName, entity);
                }
            }
            else
            {//add the new entity
                Add(entity);
            }//end else
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    /// <summary>
    /// Start Transaction
    /// </summary>
    /// <returns></returns>
    public DbTransaction BeginTransaction()
    {
        if (_ctx.Connection.State != ConnectionState.Open)
        {
            _ctx.Connection.Open();
        }
        return _ctx.Connection.BeginTransaction();
    }
    /// <summary>
    /// Delete all related entries
    /// </summary>
    /// <param name="entity"></param>        
    public void DeleteRelatedEntries(E entity)
    {
        foreach (var relatedEntity in (((IEntityWithRelationships)entity).
	RelationshipManager.GetAllRelatedEnds().SelectMany(re => 
	re.CreateSourceQuery().OfType<EntityObject>()).Distinct()).ToArray())
        {
            _ctx.DeleteObject(relatedEntity);
        }//end foreach
    }
    /// <summary>
    /// Delete all related entries
    /// </summary>
    /// <param name="entity"></param>        
    public void DeleteRelatedEntries(E entity, ObservableCollection<string> 
						keyListOfIgnoreEntites)
    {
        foreach (var relatedEntity in (((IEntityWithRelationships)entity).
		RelationshipManager.GetAllRelatedEnds().SelectMany(re => 
		re.CreateSourceQuery().OfType<EntityObject>()).Distinct()).ToArray())
        {
            PropertyInfo propInfo = relatedEntity.GetType().GetProperty
						(this._KeyProperty);
            if (null != propInfo)
            {
                string value = (string)propInfo.GetValue(relatedEntity, null);
                if (!string.IsNullOrEmpty(value) &&
                    keyListOfIgnoreEntites.Contains(value))
                {
                    continue;
                }//end if 
            }//end if
            _ctx.DeleteObject(relatedEntity);
        }//end foreach
    }
 
    #endregion
 
    #region IDisposable Members
 
    public void Dispose()
    {
        if (null != _ctx)
        {
            _ctx.Dispose();
        }
    }
 
    #endregion
 
} 

Notice that, here I also implement IDispose interface to dispose the context manually.To get the name of Entityset, here I have used typeof, but you can do a  metadata query to retrieve the EntitySet name:

container = context.MetadataWorkspace.GetEntityContainer
		(context.DefaultContainerName, DataSpace.CSpace); 

string entitySetName = (from meta in container.BaseEntitySets

                            where meta.ElementType.Name == entityTypeName

                            select meta.Name).FirstOrDefault(); 

Here I am not going to the code.

The specification pattern can implement a re-usable business logic component that can be passed around to satisfy certain business criteria. The specification object has a clear and limited responsibility, which can be separated and decoupled from the domain object that uses it. I would highly recommend reading the white paper by Martin Fowler and Eric Evans on the Specification pattern.   

public interface ISpecification<E>
{
    /// <summary>
    /// Select/Where Expression
    /// </summary>
    Expression<Func<E, bool>> EvalPredicate { get; }
    /// <summary>
    /// Function to evaluate where Expression
    /// </summary>
    Func<E, bool> EvalFunc { get; }
}

You can write your own specification by implementing your interface like RoleSpecification and put down your business logic there. For general use, you can also implement the Interface; such composite specification like this:

public class Specification<E> : ISpecification<E>
{
    #region Private Members
 
    private Func<E, bool> _evalFunc = null;
    private Expression<Func<E, bool>> _evalPredicate;
 
    #endregion
 
    #region Virtual Accessors
 
    public virtual Expression<Func<E, bool>> EvalPredicate
    {
        get { return _evalPredicate; }
    }
 
    public virtual Func<E, bool> EvalFunc
    {
        get { return _evalFunc; }
    }
 
    #endregion
 
    #region Constructors
 
    public Specification(Expression<Func<E, bool>> predicate)
    {
        _evalPredicate = predicate;
    }
 
    private Specification() { }
 
    #endregion
}

To use this Repository class from your business layer, one thing I must say that I am sharing a single context in the CRUD process/operation. You must keep alive the context in your entire process of a crud operation. For this, I make a Globalvariable of my EF ObjectContext and all using repository and in the constructor, I initialize all these variables like this: 

#region Global members
 
Repository< User, SecurityEntities> _userRepository = null;
 
Repository< Role, SecurityEntities> _roleRepository = null;
 
Repository< Task, JerichoSecurityEntities> _taskRepository = null;
 
Repository< RoleInUser,SecurityEntities> _roleInUserRepository
         = null;
 
Repository< RoleTask,SecurityEntities> _roleTaskRepository
         = null;
 
Repository< DBAuditForSecurity, SecurityEntities> _securityAuditRepository
 
SecurityEntities _ctx = null;
#endregion
 
public BLLRoleManagement()
{
    _ctx = Helper.SecurityContextInstance;
    _userRepository = new Repository< User,SecurityEntities>(_ctx);
    _roleRepository = new Repository< Role, SecurityEntities>(_ctx);
    _taskRepository = new Repository< Task, SecurityEntities>(_ctx);
    _roleInUserRepository = new Repository< RoleInUser, SecurityEntities>(_ctx);
    _roleTaskRepository = new Repository< RoleTask, SecurityEntities>(_ctx);
    _securityAuditRepository = 
	new Repository< DBAuditForSecurity, SecurityEntities>(_ctx);
}
......
..................( BLL methods , properties etc.)

Now, in my BLLRoleManagement class, say I have a method to delete User. That will be something like this:  

/// <summary>
/// Delete User
/// </summary>
/// <param name="userID">User ID</param>
/// <returns>True Or False</returns>
public static bool DeleteUser( 
    string UserID)
{
    try
    {                 
        using (DbTransaction transaction = userRepository.BeginTransaction())
        {
            User UserTobeRemoved = userRepository.SelectByKey(UserID);
            if (UserTobeRemoved == null)
                return false;
 
            userRepository.DeleteRelatedEntries(UserTobeRemoved);
            userRepository.Delete(UserTobeRemoved);
            if (userRepository.Save() >= 0)
            {
                transaction.Commit();
                return true;
            }
        }
    }
    catch (Exception ex)
    {
        throw ErrorHandler.WrapException(ex, ErrorCodes.DB_DeleteUser_Error_Code);
    }
    return false;
}

Here I just open transaction using userRepository global variable. Delete all related entities associated with User and then delete User. To share the same context in this delete process, I will call this method like this

new BLLRoleManagement().DeleteUser(userID);  

So here is my end of the discussion on repository pattern implementation with Entity framework.

License

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

About the Author

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

Comments and Discussions


Discussions posted for the Published version of this article. Posting a message here will take you to the publicly available article in order to continue your conversation in public.
 
GeneralMy vote of 5 Pinmemberdogancanbakir27-Dec-13 14:43 
QuestionIt is good but SelectByKey sucks PinmemberMember 41591745-Sep-13 13:44 
AnswerRe: It is good but SelectByKey sucks PinmemberMorshed Anwar5-Sep-13 23:15 
QuestionExample for implementing interpreter pattern Pinmembermontasir1237-Jul-13 20:37 
AnswerRe: Example for implementing interpreter pattern PinmemberMorshed Anwar7-Jul-13 23:20 
GeneralMy vote of 4 PinmemberSponaris20-Feb-13 23:00 
GeneralMy vote of 4 PinmemberGastonV7-Feb-13 20:43 
GeneralRe: My vote of 4 PinmemberMorshed Anwar8-Feb-13 11:19 
QuestionFlaws of your design PinmemberVahid_N1-Nov-12 10:08 
AnswerRe: Flaws of your design [modified] PinmemberMorshed Anwar1-Nov-12 10:25 
QuestionRe: Flaws of your design PinmemberSentenryu5-Nov-12 5:11 
GeneralMy vote of 5 Pinmembervijaysutaria1-Nov-12 3:45 
GeneralRe: My vote of 5 PinmemberMorshed Anwar1-Nov-12 3:53 
QuestionGreat Code Pinmemberpradeepvpanzade31-Oct-12 6:02 
AnswerRe: Great Code [modified] PinmemberMorshed Anwar1-Nov-12 1:09 
SuggestionRepository for Entity Framework Code-first (DbContext) PinmemberMorshed Anwar3-Oct-12 21:46 
SuggestionSuggest that you update it for dbContext & MVC4 PinmemberMember 8897653-Aug-12 13:21 
GeneralRe: Suggest that you update it for dbContext & MVC4 PinmemberMorshed Anwar3-Oct-12 21:43 
Question[My vote of 1] sorry but no... PinmemberLeonardo Paneque11-May-12 10:15 
AnswerRe: [My vote of 1] sorry but no... [modified] PinmemberMorshed Anwar12-May-12 2:10 
AnswerRe: [My vote of 1] sorry but no... Pinmembernportelli3-Apr-13 5:52 
GeneralRe: [My vote of 1] sorry but no... PinmemberLeonardo Paneque3-Apr-13 6:38 
GeneralRe: [My vote of 1] sorry but no... Pinmembernportelli3-Apr-13 7:54 
QuestionGreat! PinmemberLaserson24-Jan-12 7:18 
QuestionHow to use SQL Server View? PinmemberSunasara Imdadhusen17-Oct-11 4:03 
QuestionInteresting! But would this approach work with the entities with multiple primary keys? PinmemberRahman Mahmoodi13-Aug-11 16:11 
QuestionHow are you creating the _ctx object? Pinmemberkaschimer2-Jun-11 3:57 
QuestionWCF? PinmemberInian6-Apr-11 13:31 
Generalgreat article - working with where, join, other clauses PinmemberMauricio Sanchez28-Mar-11 6:01 
GeneralRe: great article - working with where, join, other clauses PinmemberMauricio Sanchez30-Mar-11 5:51 
GeneralMy vote of 5 PinmemberMember 150559020-Jan-11 1:26 
QuestionUsing static methods. PinmemberMartinSpasovski19-Jan-11 9:22 
AnswerRe: Using static methods. Pinmemberchjerome30-Mar-11 10:09 
QuestionCompound Key support Pinmembertr1stan9-Dec-10 3:24 
GeneralNot Comipiling PinmemberGana3-Dec-10 15:26 
GeneralRe: Not Comipiling PinmemberGana3-Dec-10 15:36 
GeneralHelp PinmemberSanjayDhooom17-Nov-10 12:56 
Questioncan you share this POCO with Repository Pattern Pinmemberraghuram Muvvala9-Aug-10 10:56 
GeneralWorking with multiple entities [modified] PinmemberHari Krishn2-Aug-10 14:19 
GeneralRe: Working with multiple entities [modified] PinmemberBillW4227-Aug-10 9:16 
QuestionWCF & IRepository [modified] Pinmemberurnelson3-Jun-10 11:18 
AnswerRe: WCF & IRepository PinmemberMorshed Anwar30-Jun-10 0:26 
GeneralGreat article!!! Pinmemberjakka3010-May-10 12:52 
GeneralRe: Great article!!! PinmemberMorshed Anwar11-May-10 22:20 
GeneralTryGetObjectByKey Pinmemberabellix26-Apr-10 10:32 
GeneralRe: TryGetObjectByKey PinmemberMorshed Anwar27-Apr-10 1:14 
GeneralRe: TryGetObjectByKey Pinmemberabellix27-Apr-10 8:05 
GeneralRe: Entity Framework made me feel sick PinmemberGermyan23-Feb-10 21:39 
QuestionSlow? PinmemberBoyfer7-Feb-10 12:54 
AnswerRe: Slow? PinmemberMorshed Anwar7-Feb-10 20:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140709.1 | Last Updated 11 Jun 2009
Article Copyright 2009 by Morshed Anwar
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid