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 8087765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:53:06+00:00 2026-06-05T18:53:06+00:00

I have an n-tier application design problem with Entity Framework 4. Server-side, my application

  • 0

I have an n-tier application design problem with Entity Framework 4.

Server-side, my application has 3 layers :
– one Service layer (WCF)
– one Business layer
– one DataAccess layer (working with EF4)

The Entities are POCO, place in a independent project/assembly.

I’m using Dependency Injection for creating objects of the business and the DataAccess layers, therefore i only work with interfaces, and I have no dependency to EF in my business layer.

I’d like to use EF Compiled Queries to improve performances.

But my (business) queries are defined in the business layer, since in my architecture, the DataAccess is only providing the CRUD methods.

So the compiled queries should be defined in business layer, but i have no dependency to EF and don’t want one to keep loose coupling, hence, i can’t call the ObjectContext from there.

And defining the queries in DataAccess does not fit my application design.

So does anyone know if there is a generic way to inject the business queries from the business layer to the DataAccess layer, so that i can use them with Compiled queries ?

I’ve tried many things and looked everywhere, and couldn’t find an answer to this … 🙁 looks like EF does not fit well with that kind of n-tier application.

  • 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-06-05T18:53:07+00:00Added an answer on June 5, 2026 at 6:53 pm

    Compiled query belongs to data access layer because it is data access specific feature dependent on data access classes. If your design doesn’t accept this it is simply not ready for data access specific features = either change your design or don’t use data access specific features.

    The simplest way is to add compliled queries to your context and expose them as methods on the context:

    public IQueryable<SomeEntity> SomeQuery(string someParam) {
        return compiledQuery.Invoke(this, someParam);
    }
    

    Now you will add these methods to the interface for the context.

    You can follow similar approach and expose compiled query on any data access interface visible in business layer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 3-tier application hosted in Tomcat; web, service and DAO layers. How
I currently have an n-tier application using entity framework 4.0 and we're looking at
We have an n-tier web application that pulls data from SQL Server. Our Data
I have a three tier system, SQL Server backend, hand written data access layer,
I have this scenario in my 3-tier app with a Service Layer that serves
I have a n-tier application based on pretty classic different layers: User Interface, Services
We have a 3 tier application - winform based thick client, several WCF services
I'm new to Entity Framework. I've created a Multi Tier Application, in MVC, using
I have a 3-tier web application using MVC - WCF - MSSQL . I
I have a three-tier application which is installed in corporate environments. With every server

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.