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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:34:56+00:00 2026-06-12T11:34:56+00:00

I am writing a RESTful API (json) in C# using WCF 4.0. Data is

  • 0

I am writing a RESTful API (json) in C# using WCF 4.0. Data is stored in a SQL Server 2012 db. One available call will allow clients to save objects, something like this:

PUT /object/123

{
Subject: "my subject",
Comment: "my comment"
}

That far all is ok. But sometimes the client only wants to update one of the parameters in an object. Like this:

PUT /object/123

{
Comment: "I changed my comment"
}

The question is: is there a best practice to make the update in the database table? How do I know what fields were supplied (given that some fields should be able to be null)? How do I write nice code that only update those columns that were supplied?

  • 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-12T11:34:57+00:00Added an answer on June 12, 2026 at 11:34 am

    Generally I do it like this. Your first example should be a POST. POST tells you it’s a create. The PUT method will tell you it’s an update, in which case I update ALL fields of object with id 123. This means the client can just send you their entire object with any/all fields updated. You just blindly copy them.

    I suppose if you didn’t want the overhead of sending all fields, you could check for a default value (null or empty string) and only update those fields which are not equal to that value.

    also check this out:

    Only update some properties on an EF entity that are not set to null

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

Sidebar

Related Questions

I'm writing a RESTful API. I'm having trouble with uploading images using the different
I've been writing simple JSON schemas but I ran into an API input call
I am in the process of writing a proof of concept RESTful server using
We are writing an application which provides a RESTful API. The application needs to
I'm writing RESTful service with C#/wcf and need to put filters on GET. Like
Background: I am writing a RESTful API on symfony. I want the client to
I'm developing a RESTful API for a client. The problem is, he's using a
I'm writing a RESTful Java server with CXF framework. How do I can write
I am writing a Spring Restful webservices application using Spring MVC. I have used
I'm writing a RESTful API module for an application in PHP, and I'm a

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.