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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:25:33+00:00 2026-06-05T20:25:33+00:00

Using the method from Steve Sanderson’s blog , I have a list of items

  • 0

Using the method from Steve Sanderson’s blog, I have a list of items that I can dynamically add to with jquery.

So, I have a list of vehicles (that belong to a Person) that I load from the DB. When I hit save, the items get binded via the standard MVC model binding mechanism, and I can just call an Update on the the Person object.

The problem exists when I dynamically add a new vehicle row. Since that vehicle did not belong to the initial list, calling Update won’t persist that new item. But, calling Create won’t work because I have the existing vehicles that need updating.

Is there an elegant way of handling this, or do I need to loop through each vehicle, check if it exists in the DB and then call Update/Edit depending on the result?

I am using NHibernate with C# in MVC3.

  • 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-05T20:25:34+00:00Added an answer on June 5, 2026 at 8:25 pm

    What method are you using for generating the ids of your entities?

    If they are being generated by nhibernate can you not just check the Id for each vehicle –

    If it is null or default (guid.empty, 0 etc depending on what the type of your Id) then it has never been near your db and needs to be inserted.

    If it has an Id then it already exists in your db and needs to be updated.

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

Sidebar

Related Questions

I am using this method to get a list of week start from my
I have called a method using a secondary thread. From inside the method i
I have a windows service which is using a method from a class library
I'm using readlines method from python to get list of all data lines. Now
I can access a method from a C++ Dll using C# using this method
I have a windows service which is using a method from a class library
I have created JSNI methods i am registering 'createCallbackFunction' method from another method using
Operating System: OSX Method: From the command line, so using sed, cut, gawk, although
I'm attempting to use the DatabaseFactory method from the Microsoft Enterprise Library. using Microsoft.Practices.EnterpriseLibrary.Data;
I noticed some odd behaviour when using the strongly typed HtmlHelper.ActionLink() extension method from

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.