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

  • Home
  • SEARCH
  • 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 7780763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:00:31+00:00 2026-06-01T19:00:31+00:00

I want to use EF Code First. I’m working with a repository pattern. And

  • 0

I want to use EF Code First. I’m working with a repository pattern. And I want to implement an n-tier architecture. What I really want is to use TDD but I’m getting a problem with aggregate routes. My problem is this…

I have a blog object. From this blog object associated files can be added. Great. So I in essence have 1 aggregate root which I create my repository for and then I need add some methods that allow me to ‘Add’ Associated Files to the blog. But where do I put this? Its a data access layer thing so I really want it there. But to be honest its also a business logic challenge. Part of the product is to be able to add assoc files. So should I put the logic to add Assoc Files in the DAL or the BLL?

Hope someone can give me some guidelines.

  • 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-01T19:00:34+00:00Added an answer on June 1, 2026 at 7:00 pm

    I think you mean DDD instead of TDD, because what you said have little meaning in context of TDD.

    You need to sit and think what does a file mean to you system, are there any rules that connects files and posts. For example if we delete a post what should have with files? Do we delete them too? Can we “add” same file to multiple posts. You sit, think, and gather knowledge about you file, then you decide if it deserve a place to be introduced in you Domain.

    Some sample domain I can imagine:

    public class Post
    {
        private List<File> _files;
        public IEnumerable<File> AssociatedFiles {get {return _files;}}
        public void AssociateFile(File file){//...}
        public void DisassociateFile(File file ){//...}
    
        //It doesn't delete it just do some logic. Maybe we can't delete this post and need to throw exception or whatever logic you need
        public void Delete()
        {
            foreach (File file in AssociatedFiles) DisassociateFile(file);
        }
    }
    
    public class File 
    {
        public String Url;
        public DateTime Created;
        public DateTime Modified;
    }
    
    public class PostRepository
    {
        public void Delete(Post post)
        {
            post.Delete();
            DbContext<Post>.Delete(post); //I Don't remember EF syntax for this
            DbContext.SaveChanges();
        }
    }
    

    Update: Let’s continue…

    After a 5 mins of thinking on you domain I descovered that my initial design misses important concepts (as always with DDD you scrape knowledge bit by bit).

    Who is responsible for uploading Files? Can user associate file he already uploaded to Post, can he add new File (unuploded) file to post? Can he mix this things? Those are important question, again you need to think about it and design you system.

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

Sidebar

Related Questions

I currently use a generic repository pattern with Entity Framework code first: public interface
1) If i want to use the asp.net membership provider in a code first
I use EF code-first 4.1. in my application. Now I want to get entities
I want to use code beside files for my views in my ASP.NET MVC
Assuming sr is an IEnumerable<string> , I want to use code like this to
I want to use regions for code folding in Eclipse ; how can that
I want to use this C code in my C++ project : mysql.c :
I want to use the following code to login to a website which returns
I want to use oscpack ( http://code.google.com/p/oscpack/ ) as a static library for my
I don't want to use any Java code, I just want to use <jsp:include>

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.