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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:47:00+00:00 2026-06-03T08:47:00+00:00

Traditional wisdom says not to call into child namespaces from a parent. Let’s say

  • 0

Traditional wisdom says not to call into child namespaces from a parent.

Let’s say I’m using something like AutoMapper to translate content models into viewmodels for an ASP.NET MVC 3 site.

My directory structure looks similar to this:

- Stuff.Content
    -Foo.cs
- Stuff.Content.Public
    -Controllers
        -FooController.cs
    -Models
        -FooViewModel.cs
    -Views
        -Foo
            -Index.cshtml
 - AutoMapperConfig.cs
 - Global.asax

AutoMapperConfig.cs in this case is just a simple static class with a static method to set up the mapping, and looks like this:

public static class AutoMapperConfig
{
    public static void Configure()
    {
        Mapper.CreateMap<Foo, FooViewModel>();
    }
}

You’ll notice I’ve got AutoMapperConfig in the root of the public project, but it’s actually calling into a child namespace (Stuff.Content.Public.Models).

Is calling into that child namespace acceptable? Should AutoMapperConfig live in the Models namespace with the viewmodels?

It seems like it gets fuzzy in this territory since it’s considered normal for controllers in the Controllers namespace to call its sibling Models namespace.

Looking forward to your thoughts. Thanks.

  • 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-03T08:47:02+00:00Added an answer on June 3, 2026 at 8:47 am

    I don’t think there’s anything wrong with your current design. Personally I put the mapping configurations into a Mappings subfolder folder:

    - Stuff.Content
        -Foo.cs
    - Stuff.Content.Public
        -Controllers
            -FooController.cs
        -Models
            -FooViewModel.cs
        -Views
            -Foo
                -Index.cshtml
        -Mappings
            -AutoMapperConfig.cs
     - Global.asax
    

    Also I tend to have a separate mapping file definition for each domain model.

    -Mappings
       -MappingRegistry.cs
       -FooProfile.cs
       -BarProfile.cs
       -...
    

    And here’s an example of FooProfile.cs:

    public class FooProfile: Profile
    {
        protected override void Configure()
        {
            CreateMap<Foo, FooViewModel>();
        }
    }
    

    and MappingRegistry.cs:

    public static class MappingRegistry
    {
        public static void Configure()
        {
            Mapper.Initialize(
                x => typeof(MappingRegistry)
                    .Assembly
                    .GetTypes()
                    .Where(type => !type.IsAbstract && typeof(Profile).IsAssignableFrom(type))
                    .ToList()
                    .ForEach(type => x.AddProfile((Profile)Activator.CreateInstance(type)))
            );
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using traditional ASP how can I return an image from a query. I want
I am using traditional XmlReader to parse a xml document into a dictionary? However
Using storyboards in lieu of the traditional .xib strategy is something I'm still wrestling
I'm into a little migration from traditional DataSets and of course continue go through
Redis is conceptually different from traditional SQL databases that I use, and I'm trying
I have a traditional web site which serves users from desktop computer browsers. I
Say I got an traditional SQL structure like so: create table tags (id PRIMARY
This is not a traditional scale-up or scale-out question. Please bear with me, here
I'm using a traditional Zend framework application generated using Zend tool . I have
I am using the traditional Asp.Net website in which I am using the System.Web.Routing

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.