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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:55:46+00:00 2026-06-17T16:55:46+00:00

When I try to update a LinqToSQL Object, the engine creates one entry in

  • 0

When I try to update a LinqToSQL Object, the engine creates one entry in DataContext.getChangeSet().Updates for each property I change.
This obviously fails due to overwrite checks…

How can I correct this behaviour (one update for all changes)?

As you can see in the generated SQL code, the properties ahvNo and insuranceNo are not recognised as changed (not in update list), but they have changed (in where query).

The first statement runs successfully, but the second one throws the exception 1 of 2 updates failed..

Here is the VB code I use:

Using dc As New WatchStoreDC()
    Dim usr = If(dc.users.SingleOrDefault(Function(u) u.id = id), New AppUser())
    usr.employeeNo = employeeNo
    usr.ahvNo = dc.formatAHVNumber(ahvNo)
    usr.insuranceNo = dc.formatInsuranceNumber(insuranceNo)
    usr.badgeNo = badgeNo
    usr.birthdate = birthdate
    usr.lastName = lastName
    usr.firstName = firstName
    usr.title = title
    usr.roles = roles

    Dim usrAct = String.Empty, mdfTim = Now
    If usr.id = 0 Then
        usrAct = "ins" : usr.createdAt = mdfTim : usr.createdByID = GeneralInfo.userID : dc.users.InsertOnSubmit(usr) : dc.SubmitChanges()
    Else
        usrAct = "upd" : usr.modifiedAt = mdfTim : usr.modifiedByID = GeneralInfo.userID
    End If

    Dim prf = If(usr.profile, New AppProfile())
    prf.languageID = profileLanguage
    prf.cultureID = profileCulture
    prf.updatedAt = mdfTim

    If prf.id = Guid.Empty Then prf.id = usr.securityID : dc.profiles.InsertOnSubmit(prf)
    dc.SubmitChanges()
End Using

This is the LinqToSQL schema:

<Table Name="app.tblUsers" Member="users">
    <Type Name="AppUser">
        <Column Name="usrID" Member="id" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
        <Column Name="usrSecurityID" Member="securityID" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsDbGenerated="true" CanBeNull="false" />
        <Column Name="usrCompanyCode" Member="companyCode" Type="System.String" DbType="NVarChar(25)" CanBeNull="true" />
        <Column Name="usrEmployeeNo" Member="employeeNo" Type="System.String" DbType="Char(6)" CanBeNull="true" />
        <Column Name="usrAHVNo" Member="ahvNo" Type="System.String" DbType="Char(14)" CanBeNull="true" />
        <Column Name="usrInsuranceNo" Member="insuranceNo" Type="System.String" DbType="Char(16)" CanBeNull="true" />
        <Column Name="usrTitle" Member="title" Type="System.String" DbType="VarChar(10)" CanBeNull="true" />
        <Column Name="usrLastName" Member="lastName" Type="System.String" DbType="NVarChar(50) NOT NULL" CanBeNull="false" />
        <Column Name="usrFirstName" Member="firstName" Type="System.String" DbType="NVarChar(50)" CanBeNull="true" />
        <Column Name="usrRole" Member="rolesInt" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
    </Type>
</Table>

This is the generated SQL:

UPDATE [app].[tblUsers]
SET [usrModifiedBy] = @p14, [usrModifiedAt] = @p15
WHERE ([usrID] = @p0) AND ([usrSecurityID] = @p1) AND ([usrCompanyCode] IS NULL) AND ([usrEmployeeNo] IS NULL) AND ([usrAHVNo] IS NULL) AND ([usrInsuranceNo] IS NULL) AND ([usrTitle] IS NULL) AND ([usrLastName] = @p2) AND ([usrFirstName] = @p3) AND ([usrLanguage] IS NULL) AND ([usrBirthdate] IS NULL) AND ([usrAddressStreetNo] = @p4) AND ([usrAddressAddLine] IS NULL) AND ([usrAddressZIP] = @p5) AND ([usrAddressCity] = @p6) AND ([usrAddressCountry] = @p7) AND ([usrPhoneWork] IS NULL) AND ([usrPhoneHome] = @p8) AND ([usrPhoneMobile] IS NULL) AND ([usrEMailWork] IS NULL) AND ([usrLogin] IS NULL) AND ([usrSiteLocation] IS NULL) AND ([usrSiteNo] IS NULL) AND ([usrUnitCenter] IS NULL) AND ([usrDepartment] IS NULL) AND ([usrOE] IS NULL) AND ([usrOEName] IS NULL) AND ([usrCostCenter] IS NULL) AND ([usrCCResponsible] IS NULL) AND ([usrSuperior] IS NULL) AND ([usrJoinDate] IS NULL) AND ([usrExitDate] IS NULL) AND ([usrExitReason] IS NULL) AND ([usrBadgeNo] IS NULL) AND ([usrContractType] IS NULL) AND ([usrContractTypeName] IS NULL) AND ([usrPayrollContact] IS NULL) AND ([usrHRContact] IS NULL) AND ([usrApprovals] = @p9) AND ([usrPaymentType] = @p10) AND ([usrRole] = @p11) AND ([usrEMailContact] IS NULL) AND ([usrPhoneContact] IS NULL) AND ([usrCreatedBy] = @p12) AND ([usrCreatedAt] = @p13) AND ([usrModifiedBy] IS NULL) AND ([usrModifiedAt] IS NULL) AND ([usrSignature] IS NULL) AND ([usrSignatureMIME] IS NULL)

UPDATE [app].[tblUsers]
SET [usrModifiedBy] = @p15, [usrModifiedAt] = @p16
WHERE ([usrID] = @p0) AND ([usrSecurityID] = @p1) AND ([usrCompanyCode] IS NULL) AND ([usrEmployeeNo] IS NULL) AND ([usrAHVNo] = @p2) AND ([usrInsuranceNo] IS NULL) AND ([usrTitle] IS NULL) AND ([usrLastName] = @p3) AND ([usrFirstName] = @p4) AND ([usrLanguage] IS NULL) AND ([usrBirthdate] IS NULL) AND ([usrAddressStreetNo] = @p5) AND ([usrAddressAddLine] IS NULL) AND ([usrAddressZIP] = @p6) AND ([usrAddressCity] = @p7) AND ([usrAddressCountry] = @p8) AND ([usrPhoneWork] IS NULL) AND ([usrPhoneHome] = @p9) AND ([usrPhoneMobile] IS NULL) AND ([usrEMailWork] IS NULL) AND ([usrLogin] IS NULL) AND ([usrSiteLocation] IS NULL) AND ([usrSiteNo] IS NULL) AND ([usrUnitCenter] IS NULL) AND ([usrDepartment] IS NULL) AND ([usrOE] IS NULL) AND ([usrOEName] IS NULL) AND ([usrCostCenter] IS NULL) AND ([usrCCResponsible] IS NULL) AND ([usrSuperior] IS NULL) AND ([usrJoinDate] IS NULL) AND ([usrExitDate] IS NULL) AND ([usrExitReason] IS NULL) AND ([usrBadgeNo] IS NULL) AND ([usrContractType] IS NULL) AND ([usrContractTypeName] IS NULL) AND ([usrPayrollContact] IS NULL) AND ([usrHRContact] IS NULL) AND ([usrApprovals] = @p10) AND ([usrPaymentType] = @p11) AND ([usrRole] = @p12) AND ([usrEMailContact] IS NULL) AND ([usrPhoneContact] IS NULL) AND ([usrCreatedBy] = @p13) AND ([usrCreatedAt] = @p14) AND ([usrModifiedBy] IS NULL) AND ([usrModifiedAt] IS NULL) AND ([usrSignature] IS NULL) AND ([usrSignatureMIME] IS NULL)
  • 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-17T16:55:47+00:00Added an answer on June 17, 2026 at 4:55 pm

    After some more searching on google, I found another question which solved my problem.

    The problem was as follows:
    I was generating the hash code based on this properties.

    I have now added a private variable to store the first generated hashcode.

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

Sidebar

Related Questions

I try to update database table and this is my code: public void updatefiletable(String
I try to update my profile image and use this code: $connection->post('account/update_profile_image', array('image' =>
I have this code for update: public Boolean update() { try { data.put(ContactsContract.Groups.SHOULD_SYNC, true);
I try update num_of_gifts without select use yii active record and CDbCriteria this is
I try to update the data making use of checkboxes. But when one or
am getting this error once i try to update a bit field with null.
when i try to update one table(GLOBAL_VARIABLES) from information_schema db, i get an error
I try to update customers App in Google Play, this is my first time
when i try to update a table the app crashing and return this fatal
I try to update a column in an table with the following query. In

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.