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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:37:02+00:00 2026-06-03T08:37:02+00:00

In our database we have a user. A user can have certain metadata (Like

  • 0

In our database we have a user. A user can have certain metadata (Like their location, age, etc) associated with them. In addition to that they have a profile image.
A user can edit any of these things at any time.

enter image description here

The problem we run into is that when a user goes to edit their information, but they don’t choose an image — the previous image gets erased (Null).

I figure that when we go to save the modified user, we should be able to say if(user.profileImage == null) don't save it

I figure that would come into play in our user repository which uses the following code:

public void SaveUser(Domain.Entities.User user)
        {
            if (user.UserId == 0)
            {
                context.Users.Add(user);
            }
            else
            {
                context.Entry(user).State = EntityState.Modified;
                //The logic would be here
            }
            context.SaveChanges();
        }

However I seems that no matter what we try it doesn’t work.

So my question is: Is there a way to check changes to individual fields instead of the entire EntityState?

  • 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-03T08:37:03+00:00Added an answer on June 3, 2026 at 8:37 am

    I ended up storing image data in the Session and then if the image upload was null I simply inserted the session attribute into my image, effectively keeping the old image if left empty.

    Session["image"] = productService.GetProduct(id).Image;

    Then in the post I said…

    if (image != null)
                    {
                        product.ImageType = image.ContentType;
                        product.Image = new byte[image.ContentLength];
                        image.InputStream.Read(product.Image, 0, image.ContentLength);
                    }
                    else
                    {
                        product.Image = (byte[])Session["image"];
                    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have scalar functions in our database for returning things like number of tasks
Every so often I have to remove a user from our database. Users are
In our application user can create different lists (like sharepoint) for example a user
Our database server is a SQL 2008 server. My colleagues all have XP service
I have 100000 Ids to store into our DataBase. Id is in string format.each
We are moving our database server to a bigger box. I have several databases
We have a whole bunch of DLLs that give us access to our database
We've encountered the following situation in our database. We have table 'A' and table
In our current database development evironment we have automated build procceses check all the
We have been storing our staging database on the production database server with the

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.