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

I need to have a user select their address in our address database (I'm
I have an asp.net application where the users can upload files to our database.
I have a drawing app where the user can draw lines with their finger,
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
We have a website wherein a user can post information from our website to
I have 100000 Ids to store into our DataBase. Id is in string format.each
We've encountered the following situation in our database. We have table 'A' and table
We have been storing our staging database on the production database server with the
We have recently improved the schema of our production database, changing column names and

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.