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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:43:43+00:00 2026-05-26T22:43:43+00:00

I am using C#, EF and SQL Server and have few tables with parent-child

  • 0

I am using C#, EF and SQL Server and have few tables with parent-child relationship. There are more than 2 but in this example I will use only 2 for simplicity.

Table Book

Id
DateModified
RowVersion

Table Page

Id
BookId - this is foreign key to Book.Id
RowVersion

When any page/pages are updates I need to update DateModified in Book table.

We are using RowVersion to keep track of changes, since it’s unique value I want to always be able to get the latest changes for each book by simply doing something like

SELECT * FROM Page
WHERE RowVersion > Book.RowVersion

But in order to do this I need to make sure that RowVersion in Book table is ALWAYS updated before RowVersions in Pages.

In my EDM layer I currently have something like this:

class Page
{
  void OnPageChanged() //this is hooked to OnPropertyChanged
  {
     this.Book.UpdateDateModified(DataTime.Now);
  }
}

Doing this results in page being updated first and its RowVersion is updated first too after the transaction commits. Which is not what I need.

Question, if I will move OnPageChanged() to be handling OnPropertyChanging event instead – will this guarantee the consistency? Is it OnPropertyChanged that dictates the order the updates happen in sql generated by EF? Any other suggestions for this case?

  • 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-26T22:43:43+00:00Added an answer on May 26, 2026 at 10:43 pm

    I don’t think this is possible. I cannot try it now but I have real doubts that you can compare timestamps (RowVersion) in Linq query. It is mapped to byte array and byte array is not comparable. The order of operations in the database is absolutely out of your control. You cannot base your logic on expected order in which the entities will be updated. You can do it only if your pages and book will be saved by two different SaveChanges calls. In such case you cannot use OnPropertyChanges at all and you must handle Book change manually before you make any change to your pages.

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

Sidebar

Related Questions

I have a database with a few tables running on SQL Server 2008, and
I'm using SQL-SERVER 2005. I have two tables as you can see on diagram,
I'm using SQL-Server 2005. I have two tables Users and Payments which has a
I'm using SQL Server 2008 Management studio viewing a 2005 server and have just
[using SQL Server 2005] I have a table full of users, I want to
Using MS SQL Server .I have made a Stored Procedure named SP_Get_CallsLogged . I
We are using SQL Server 2000 and have to move data across servers to
I am using SQL Server 2000 and I have two databases that both replicate
I'm using SQL Server 2005 express I have a datetime field in a table
I am using Microsoft SQL Server and I have a master-detail scenario where I

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.