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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:43:38+00:00 2026-06-12T07:43:38+00:00

a) Domain entities shouldn’t contain code related to persistence, thus they should be Persistence

  • 0

a) Domain entities shouldn’t contain code related to persistence, thus they should be Persistence Ignorant PI. But assuming Domain Model DM is designed using Entity Framework and assuming that service layer performs CRUD operation for POCO domain entities via Linq-to-Entities, would we argue that service layer accesses DAL directly or via Domain Model:

class CustomerService
{
       public string doSomething( ... )
       {
                ...
                var customer = context.Customers.Where( ... );
                ...
        }
       ...
}

b) Does using Linq-to-Entities within DM violate PI rule? For example, does the following Customer entity violate PI:

class Customer
{
       public string InterestedWhatOtherCustomerOrdered( ... )
       {
                ...
                var orders = context.Orders.Where( ... ); // does this violate PI rule?
                ...
        }
       ...
}

REPLY TO Luke McGregor:

a)

Yeah it does as it refers to the context directly. A better way would
be to use the internal navigation properties on Customer to perform
the same action,

So instead navigation properties should contact the context?! But since navigation properties also reside within domain model, couldn’t we then argue that by contacting the context directly, they too would violate PI?

b) According to Fowler’s PEAA chapter on Data Mapper, it is ok to extract from Data Mapper any methods needed by the domain code into an interface class, which domain code can then use. How exactly could that be done when using EF instead of hand written Data Mapper, in such a manner that we wouldn’t violate PI?

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-06-12T07:43:40+00:00Added an answer on June 12, 2026 at 7:43 am

    Yeah it does as it refers to the context directly. A better way would be to use the internal navigation properties on Customer to perform the same action,

    class Customer
    {
           public string InterestedWhatOtherCustomerOrdered( ... )
           {
                    ...
                    var orders = this.Orders;
                    ...
            }
           ...
    }
    

    or to create a separate query class for this function.

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

Sidebar

Related Questions

Domain entities shouldn't contain code related to persistence, thus they should be Persistence Ignorant
We have bunch of Domain Entities which should be rendered to an html format,
Should Domain Entities be exposed as Interfaces or as Plain Objects ? The User
Is it possible to use the @Html.EditorForModel() method but not pollute my Domain entities
I'm writing an application and started to test my domain model entities. If I
I have created domain model and define entities, value objects, Services and so on.
I am thinking of making all my entities in my domain model implement INotifyPropertyChanged
For domain entities, should property names be prefaced with the entity name? I.E. my
I have this partial view rendered multiple times on a page: @model POS.Domain.Entities.Category <div
I have my entities such as Customer, Order etc. defined in my Domain Model.

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.