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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:08:44+00:00 2026-05-29T21:08:44+00:00

Maybe I’m missing something obvious, or maybe something sinister is happening, but this seems

  • 0

Maybe I’m missing something obvious, or maybe something sinister is happening, but this seems strange to me. I have a Linq to SQL data context and I’m trying to update a field on a record. The update wasn’t working, and a SQL Profiler trace showed that no update command was being issued to the database. So I narrowed down the exact lines of code and removed various variables to try to simplify.

With the where clauses unchanged, what’s going on in the debugger right now is as follows:

var foo = db.f_pp_Budgets
            .Where(b => b.SeasonKey == seasonID)
            .Where(b => b.Business == businessUnit)
            .Where(b => b.Level == "R")
            .Where(b => b.CodeKey == region.Key)
            .Single().Trade;
// foo is now set to 1
db.f_pp_Budgets
            .Where(b => b.SeasonKey == seasonID)
            .Where(b => b.Business == businessUnit)
            .Where(b => b.Level == "R")
            .Where(b => b.CodeKey == region.Key)
            .Single().Trade = region.Budget.Trade;
// region.Budget.Trade was (and still is) 2
// so the underlying Linq to SQL object should have a 2 in it, right?
var baz = db.f_pp_Budgets
            .Where(b => b.SeasonKey == seasonID)
            .Where(b => b.Business == businessUnit)
            .Where(b => b.Level == "R")
            .Where(b => b.CodeKey == region.Key)
            .Single().Trade;
// baz is set to 1.  Shouldn't it be 2?

Since the value is unchanged, calling db.SubmitChanges() naturally doesn’t send anything to the database.

Can anybody think of a reason why the value wouldn’t be changing?


Updated code: (in response to @Hogan’s answer)

var myObj = db.f_pp_Budgets
              .Where(b => b.SeasonKey == seasonID)
              .Where(b => b.Business == businessUnit)
              .Where(b => b.Level == "R")
              .Where(b => b.CodeKey == region.Key)
              .Single();

var foo = myObj.Trade;
// foo is now set to 1

myObj.Trade = region.Budget.Trade;
// region.Budget.Trade was (and still is) 2

var baz = myObj.Trade;
// baz is now set to 2

The object’s value is being updated. However, db.SubmitChanges() still doesn’t send any update statements to the database.

  • 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-29T21:08:46+00:00Added an answer on May 29, 2026 at 9:08 pm

    Found the problem. It looks like the System.Data.Linq.Table<> object was set to .IsReadOnly = true because the underlying table had no primary key. Makes sense, since Linq wouldn’t really have a reliable way of tracking the uniqueness of entities if no unique identifier is supplied from the database.

    One would hope that the generated code for the entities could make properties on the affected type without setters, or throw an exception on setting. But there may be other good reasons why that isn’t the case, of which I am unaware.

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

Sidebar

Related Questions

Maybe this is something I am just missing, but is there any way to
Maybe this is a dumb question, but I have the following behavior in Visual
Maybe this question is kind of silly but I have no clue how to
Maybe this is gonna sound naive and all, but is there something even remotely
Maybe I'm missing something but why does visual studio break execution to tell me
Maybe this is just obvious to everyone but can someone explain where XOR (or
Maybe I'm missing something simple but I can't figure out after some time looking
Maybe this is a really dumb question, but please hear me out. I have
Maybe there is something screwy with Coldfusion's Ajax functions, but I cant figure this
Maybe this is very basic, but I am all confused. I have a simple

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.