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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:08:39+00:00 2026-06-10T05:08:39+00:00

I am trying to create a small personal project which uses EF to handle

  • 0

I am trying to create a small personal project which uses EF to handle data access. My project architecture has a UI layer, a service layer, a business layer and a data access layer. The EF is contained within the DAL. I don’t think it’s right to then make reference to my DAL, from my UI. So I want to create custom classes for ‘business objects’ which is shared between all my layers.

Example: I have a User table. EF creates a User entity. I have a method to maybe GetListOfUsers(). That, in the presentation, shouldn’t reply on a List, as the UI then has a direct link to the DAL. I need to maybe have a method exposed in the DAL to maybe be something like:

List<MyUserObject> GetListOfUsers();

That would then call my internal method which would GetListOfUsers which returns a list of user entities, and then transforms them into my MyUserObejcts, which is then passed back through the layers to my UI.

Is that correct design? I don’t feel the UI, or business layer for that matter, should have any knowledge of the entity framework.

What this may mean, though, is maybe I need a ‘Transformation layer’ between my DAL and my Business layer, which transforms my entities into my custom objects?

Edit:

Here is an example of what I am doing:

I have a data access project, which will contain the Entity Framework. In this project, I will have a method to get me a list of states.

public class DataAccessor
{
    taskerEntities te = new taskerEntities();

    public List<StateObject> GetStates()
    {
        var transformer = new Transformer();
        var items =   (from s in te.r_state select s).ToList();
        var states = new List<StateObject>();
        foreach (var rState in items)
        {
            var s = transformer.State(rState);
            states.Add(s);
        }
        return states;
    }

}

My UI/Business/Service projects mustn’t know about entity framework objects. It, instead, must know about my custom built State objects. So, I have a Shared Library project, containing my custom built objects:

namespace SharedLib
{

    public class StateObject
    {
        public int stateId { get; set; }
        public string description { get; set; }
        public Boolean isDefault { get; set; }
    }


}

So, my DAL get’s the items into a list of Entity objects, and then I pass them through my transformation method, to make them into custom buily objects. The tranformation takes an EF object, and outputs a custom object.

public  class Transformer
    {
        public StateObject State (r_state state)
        {
            var s = new StateObject
                        {
                            description = state.description, 
                            isDefault = state.is_default, 
                            stateId = state.state_id
                        };

            return s;
        }
    }

This seems to work. But is it a valid pattern?

  • 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-10T05:08:41+00:00Added an answer on June 10, 2026 at 5:08 am

    So, at some point, your UI will have to work with the data and business objects that you have. It’s a fact of life. You could try to abstract farther, but that would only succeed in the interaction being deferred elsewhere.

    I agree that business processes should stand alone from the UI. I also agree that your UI should not directly act with how you access your data. What have you suggested (something along the lines of “GetListOfUsers()”) is known as the Repository Pattern.

    The purpose of the repository pattern is to:

    separate the logic that retrieves the data and maps it to the entity
    model from the business logic that acts on the model. The business
    logic should be agnostic to the type of data that comprises the data
    source layer

    My recommendation is to use the Repository Pattern to hide HOW you’re accessing your data (and, allow a better separation of concerns) and just be concerned with the fact that you “just want a list of users” or you “just want to calculate the sum of all time sheets” or whatever it is that you want your application to actually focus on. Read the link for a more detailed description.

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

Sidebar

Related Questions

I'm trying to create a small web service to convert PDF files to a
Im trying to create a small application where a user submit personal info and
I am trying to create a small animated effect with jquery in which images
I'm trying create a small http proxy service. This is not working so well.
I'm trying to create a small 2D game in Javascript/Canvas which consists of several
I am trying to create a small applescript which will launch the DVD Player
I'm trying to create a small ffmpeg hack which enables parallel executin of the
I'm trying to create a small website in ASP.NET MVC that uses twitter. I
I'm playing around with MVC3, trying to create small test projects which simulate problems
I'm trying to create a small flash-app, which needs to run as big as

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.