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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:07:42+00:00 2026-05-21T05:07:42+00:00

I am inserting a UserStat record–nothing out of the ordinary so far as I

  • 0

I am inserting a UserStat record–nothing out of the ordinary so far as I can tell. The basic idea is to iterate a set of values, Stats, and create UserStat records copying some of the Stat data.

However, when I debug, immediately after any userStat.Value = <some number>; statement, the value of .Value is still 0.0. It’s a float in the SQL Server database if that matters. But, the .AnotherProperty and .SomeOtherProp fields in the db are also floats–they are saved perfectly.

My consistent and reproducible problem is that .Value never persists (even in the local instance) when being modified. Maybe this needs a fresh pair of eyes–am I missing something that should be obvious?

        using (MyDataContext db = new MyDataContext())
        {
            List<UserStat> stats = new List<UserStat>();

            // create stats
            foreach (var stat in db.Stats)
            {
                UserStat userStat = new UserStat()
                {
                    // set some common properties
                };

                switch (stat.ID)
                {
                    case (int)Enums.Stats.Stat1:
                        userStat.Value = 1;
                        // right here, userStat.Value == 0 is true...HUH?
                        userStat.AnotherProperty = 2;
                        userStat.SomeOtherProp = 5;
                        break;
                    case (int)Enums.Stats.Stat2:
                        userStat.Value = 5;
                        // right here, userStat.Value == 0 is true...HUH?
                        break;

                    default:
                        break;
                }

                stats.Add(userStat);
            }

            db.UserStats.InsertAllOnSubmit(stats);

            db.SubmitChanges();
        }

Update

Yes, it’s my fault. I had a partial class definition on UserStat for OnValueChanged() that was making a business modification I implemented too long ago to remember as it was the only business modification on that class while others have many I constantly debug.

  • 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-21T05:07:42+00:00Added an answer on May 21, 2026 at 5:07 am

    Oops–I missed a partial class definition that modified UserStat in the .OnValueChanged() definition.

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

Sidebar

Related Questions

Inserting rows one by one from a 600 record data-set is taking almost an
When inserting a record to a database, the server returns an 'undefined index: category',
When inserting a row in mysql database, string values need to be enclosed in
When inserting values into my table what do I edit here? Do I delete
I am inserting field values in Sitecore using Sitecore web service. If my field
I'm inserting the result set returned from a CLR stored procedure into a table
Afetr inserting a new record into my CoreData store using an NSFetchedResultsController, when I
When inserting values into TARGET_TABLE with below INSERT..SELECT statement, the column default for the
I'm currently inserting a record into a SQL Server Table and then selecting the
[After inserting a record in SQLite] I want to get last inserted id but

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.