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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:11:23+00:00 2026-05-25T12:11:23+00:00

When you work with ORM which implement UnitOfWork pattern (NHibernate’s Session, Entity Framework’s ObjectContext,

  • 0

When you work with ORM which implement UnitOfWork pattern (NHibernate’s Session, Entity Framework’s ObjectContext, etc.), there are two types of data services methods: those which save/commit changes and those which just modify model properties.

In some time it becomes difficult to support this mess: when you call a method you are not sure, whether it will save changes or not (if it doesn’t you need to do it in some of outer methods).

How can I solve this problem? The only idea I have is a special naming. For example, AddCustomer for saving method and FillForAddCustomer for non-saving method. Any other ideas?

  • 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-25T12:11:23+00:00Added an answer on May 25, 2026 at 12:11 pm

    There are a couple of ways to handle this, and they each have their own pros and cons.

    The first way would be to do something like you suggest and handle the difference between “persisted” methods and “un-persisted” methods via convention. Ruby takes a similar approach with methods by indicating “dangerous” methods (ie those that modify the object they are called on or their arguments) by ending the method name with an exclamation mark (!). Depending on your development culture, such a convention may work very well, or it may not. The problem I have with conventions like this is that it’s one more thing I have to remember, is hard to check for consistency, and is less obvious to someone new to the codebase that the convention exists.

    Another way to approach the problem is to use the Command Query Responsibility Segregation (CQRS) pattern. The idea here is that rather than have one Repository for a domain object that takes care of both getting the persisted objects, and persisting new or updated ones, you split those two responsibilities up. In addition to it being much more clear regarding which methods persist things (you are using classes from entirely different namespaces), you are also separating the reading from the writing, which allows for more easily tuning the application for better performance down the road.

    Some may argue that, for purposes of simply knowing which methods persist and which don’t, CQRS is the same thing as a naming convention, just moved up a level. While that is true to some extent, by moving the convention up to the namespace level, rather than the method name level, you are able to better trace, via dependency graphs, if you are being inconsistent with where persisting is taking place and allows you to refactor more easily.

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

Sidebar

Related Questions

The RoR tutorials posit one model per table for the ORM to work. My
At my work we recently finished the system architecture for a control application which
is there a python ORM (object relational mapper) that has a tool for automatically
at first i'm really new to ORM, nhibernate and FHN. i look into this
I need to solve the following question which i can't get to work by
At work we are currently still using JUnit 3 to run our tests. We
At work we are being asked to create XML files to pass data to
I work in VBA, and want to parse a string eg <PointN xsi:type='typens:PointN' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
I work with C# at work but dislike how with webforms it spews out
At work, we have multiple branches that we may be working on at any

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.