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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:18:28+00:00 2026-05-17T17:18:28+00:00

So, if I want to add a new object to my database, I can

  • 0

So, if I want to add a new object to my database, I can write this:

public ActionResult Something(SomeObject Object) {
    if (ModelState.IsValid()) {
        DataContext.SomeObjects.InsertOnSubmit(Object);
        DataContext.SubmitChanges();
    };
}

But, how does validation get called when I want to update an object? Does UpdateModel<T> automatically perform the validation or do I have to do something to tell it to or do I have to do something ahead of calling UpdateModel<t>?

EDIT:

For @SLaks, so do I do something like this:

UpdateModel<SomeObject>(Object);

if (ModelState.IsValid()) {
    DataContext.SubmitChanges();
};

Or, if I’m butchering that, please show me the right way.

  • 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-17T17:18:28+00:00Added an answer on May 17, 2026 at 5:18 pm

    Your original question seemed to be “how does validation get called?”.

    The validation is called on the object if it implements the IDataErrorInfo interface. IDataErrorInfo is implemented in the Model Binder – this happens just before the execution is passed to your Action.

    So, answer in short: You don’t have to tell it to do something if your using DataAnnotations. The validation happens automatically before you get to the Action’s code. That’s why ModelState.IsValid() returns a value – because the validation has completed.

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

Sidebar

Related Questions

I want add new Feed item on entity persist and update. I write this
I want to add a new property bool IsValid to my class below. I
I want to create a new AnswerStat object and save it in the database.
I want to add new obj of JSON like: 128: { Msg: [{ me:
I am working with an NSOperationQueue and I want to add new NSOperations to
I've following Grid to display data, now when I want to add new record
I want to test Add new item activity in my application. When user fills
I want to add a new row to my JSON when the user clicks
I want to add a new tab page for every newly opened form. Example:
I want to add a new filter to the Project Explorer, to hide 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.