Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6226573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:03:26+00:00 2026-05-24T09:03:26+00:00

I have implemented Generic repository which only depends on IUnitOfWork (in Infrastructure.Repositories Library) and

  • 0

I have implemented Generic repository which only depends on IUnitOfWork (in Infrastructure.Repositories Library) and also haven’t used any references to Entity Framework 4.1 dll. Entity Framework’s DbContext wrapped with EFUnitOfWork which is in different class library called Infrastructure.EntityFramework. However, I came across some difficulty with Linq to Entity query that may force me to include direct dependancy with repository and EF 4.1 library.

In one of my class repository I need to use following query with a join. How can I overcome DBContext usage in my repository ?

var result = from cc in ProjectXEFDbContext.CurrentContext().PurchaseOrderLineItemCollection
                     join bb in GetQuery() on cc.PurchaseOrderId equals bb.Id
                     where bb.Id == purchaseOrder.Id && cc.Total > 50
                     select cc;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:03:27+00:00Added an answer on May 24, 2026 at 9:03 am

    I made my repositories to expose IQuerables over DbContext. DbContext wrap with UnitOfWork as follows

    My Repository base goes like this

        /// <summary>
        /// Gets the query.
        /// </summary>
        /// <returns></returns>
        public IQueryable<TEntity> GetQuery()
        {
            return this.UnitOfWork.GetQuery<TEntity>();
        }
    
        /// <summary>
        /// Loads the type.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public IQueryable<T> LoadType<T>() where T : class
        {
            return this.UnitOfWork.GetQuery<T>();
        }
    

    my unit of work implementation goes here

        /// <summary>
        /// Gets the query.
        /// </summary>
        /// <typeparam name="TEntity">The type of the entity.</typeparam>
        /// <returns></returns>
        public IQueryable<TEntity> GetQuery<TEntity>() where TEntity:class 
        {
            return this.DbContext.Set<TEntity>();
        }
    

    Changes to my query as follows

            var result = from cc in GetQuery()
                         join bb in LoadType<PurchaseOrderLineItem>() on cc.Id equals                      bb.PurchaseOrderId
                         where cc.Id == purchaseOrder.Id && bb.Total > 50
                         select bb;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a generic interface IConstrained which is implemented by the generic Constrained class.
I have implemented in the Add() method of my generic EF repository a check
I have implemented the repository pattern using the following generic interface. public interface IRepository<T>
I have implemented pagination to my data, but the problem is I only have
I have implemented a repository pattern in my asp.net mvc web application... But i
I have a base repository contract which other contracts extend, like follows public interface
I am writing a generic repository to interface with EF using DBContext. I have
I have implemented a set datatype in javascript based in a generic object type,
For Code First CTP 3 and 4 I had a generic repository pattern implemented
Hi looking at the repository pattern which commonly seems to be implemented something like:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.