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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:27:49+00:00 2026-06-15T07:27:49+00:00

From what I have read POCO classes should be persistence ignorant and should not

  • 0

From what I have read POCO classes should be persistence ignorant and should not contain references to repositories.

Q1. Given the above, how would I populate the QuestionBlocks collection? I have read that POCO’s should contain behavior so you don’t end of with an anemic model, so I’m kind of confused as how one is supposed to do that without persistence. If that’s the case then what kind of behavior would you put in a POCO?

Ex:

 public class Survey
    {
        public int SurveyId { get; set; }
        public string Title { get; set; }
        public int BrandId { get; set; }
        public DateTime Created { get; set; }
        public List<SurveyQuestionBlock> QuestionBlocks { get; set; }

        [ResultColumn]
        public string Name { get; set; }


        /// <summary>
        /// Constructor
        /// </summary>
        public Survey()
        {
            Created = DateTime.Now;
            QuestionBlocks = new List<SurveyQuestionBlock>();
        }
    }
  • 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-15T07:27:50+00:00Added an answer on June 15, 2026 at 7:27 am

    Given the above, how would I populate the QuestionBlocks collection?

    When reading from a database, the persistence infrastructure should populate the QuestionBlocks collection – reconstitution. Reconstruction should not invoke behavior, it should only set appropriate fields on the POCO. This is the responsibility of the repository. A repository is typically referenced from an application service, which sets up the stage for invoking entity behavior.

    If that’s the case then what kind of behavior would you put in a POCO?

    The behavior in the POCO entity should be concerned with making changes to the entity itself as well as maintaining invariants – ie ensuring the integrity of the entity. In your example, the simplest kind of behavior on the POCO should be method for adding a new question block to the collection on the survey. Ideally, you would make many of the properties on the survey entity read-only:

        public class Survey
        {
            public int SurveyId { get; private set; }
            public string Title { get; private set; }
            public int BrandId { get; private set; }
            public DateTime Created { get; private set; }
            public IList<SurveyQuestionBlock> QuestionBlocks { get; private set; }
            public string Name { get; private set; }
    
            public void AddQuestionBlock(string questionBlockInfo)
            { 
              this.QuestionBlocks.Add(new SurveyQuestionBlock(...));
            }
    
            public Survey()
            {
                Created = DateTime.Now;
                QuestionBlocks = new List<SurveyQuestionBlock>();
            }
        }
    

    The persistence layer should be able to set the values of the read-only properties via reflection. You can go a step further and only expose the question blocks collection as a read-only collection to ensure that it can only be modified from within the entity itself.

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

Sidebar

Related Questions

From what I have read java (usually) seems to compile java to not very
From what I have read, I found that a built-in ternary operator does not
I have read from the Wikipedia that: References cannot be null, whereas pointers can;
From what I have read best practice is to have classes based on an
I have read from some article that say's Apple doesn't approve the application which
I have read from this article http://codahale.com/how-to-safely-store-a-password/ and it says using a salt isn't
I have read from the question How to gain access to a ServletContext instance
From what I have read Quantity on Hand is the physical number of Items
From what I have read, CQRS designs involve asynchronous commands where commands are put
I'm in the process of learning Databases and SQL. From what I have read

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.