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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:23:04+00:00 2026-05-23T11:23:04+00:00

I’m trying to grasp DDD here, and I’ve read somewhere that it is possible

  • 0

I’m trying to grasp DDD here, and I’ve read somewhere that it is possible to reuse the domain entities as viewmodels. I’ve created a simple CRUD app, but at the U(pdate), I get a bit stuck at “?????”:

// snippet of the content of the ItemController:
public ViewResult Edit(Guid id)
{
    Item item = _itemDomainService.GetFromCurrentUser(id);
    return View(item);
}

[HttpPost]
[Transaction]
public ViewResult Edit(Item item)
{
    // Validate here

    //????
    return Redirect("Item", "Details", item.Id);
}

I’m using nhibernate with the session per request pattern (“Transaction” is a custom attribute). But “item” is not “tracked” (it is transient) to the nhibernate session. What is the preferred method of getting the changes in “item” into the corresponding row in the database?

I’m thinking of the folowing options myself:

  • Map all properties to the persistent “item”, so (at the “????”):

    var fromDB = _itemDomainService.GetById(item.Id);
    fromDB.Name = item.Name;
    fromDB.Description = item.Description
    // etc
    
  • Attach the item to session:

     // of course session would be abstracted away, but for brevity pretend it gets injected into the controller
     session.Update(item);
    
  • My design is plain wrong, and I need to (for example) not use the session-per request…

What are your thoughts on this?

  • 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-23T11:23:05+00:00Added an answer on May 23, 2026 at 11:23 am

    Hmm, tricky because I know MVC but not NHibernate. I do know Entity Framework though so I’ll assume they are similar enough for this to still be useful I hope:

    I would do something like:

    //get the original item from the DB
    var fromDB = _itemDomainService.GetById(item.Id);
    
    //update fromDB with values from the current "Item" that was posted
    UpdateModel(fromDB);
    
    //then save the changes that were made
    _itemDomainService.SaveChanges();
    //this last line is how it is done in Entity Framework - but I guess there is something similar in NHibernate
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.