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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:56:26+00:00 2026-05-17T16:56:26+00:00

I have an ASP.NET MVC 2 project. I’ve decoupled layers. I have a service

  • 0

I have an ASP.NET MVC 2 project. I’ve decoupled layers. I have a service layer and a repository layer.
The controller calls service methods and only the service layer calls methods in the repository.

The problem is:
A method in my repository class uses LINQ joins. From this method, I would like to return a type with merging some data from joined tables. (i.e, Name = a.Name, Position = b.Position) And I always return IEnumerables in my repository class. So in this case, it seems I need to define a new type for (Name, Position), and return that type from the repository function. But, then, I’ll have to remap that class to some other ViewModel class. (Because I’m seperating concerns, I shouldnt use viewmodel classes in repository right?) This leads to many different classes. EF classes, classes for joined tables, and viewmodel classes.

Am I in the right path?

Please enlighten me.

Thank you

  • 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-17T16:56:27+00:00Added an answer on May 17, 2026 at 4:56 pm

    Consider defining those classes at the repository layer. Essentially they’re DTO classes, and it sounds like you were on the track I’d have taken.

    Any reason why you were expecting to remap that class to some other ViewModel class?

    public class EmpPosition()
    {
        public property Name{get;set;}
        public property Position{get;set;}
    }
    
    //Repo
    public IEnumerable<EmpPosition> GetEmployeePositions()
    {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say you have an ASP.NET MVC project and are using a service layer, such
I have an asp.net mvc 3 project and I have a home controller. I
I have an asp.net mvc project that uses some search methods in a seperate
I have ASP.Net MVC project. Plus wordpress blog under a subfolder /Blog. Now, when
I have an ASP.NET MVC project with xVal and data annotations and I need
We have an ASP.Net MVC project that will start with a single web server
I have an Asp.net MVC project that modestly uses jQuery scripts. My views also
I have a new asp.net mvc project and i am trying to figure out
In Visual Studio 2010 I have an ASP.NET MVC 3 project called blahblah. As
In our ASP.NET MVC project we have a Strings.resx file and the accompanying autogenerated

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.