Skip to content

Fix EF double-write in InterviewSessionRepository#14

Open
KhawarHabibKhan wants to merge 1 commit intoAzure-Samples:mainfrom
KhawarHabibKhan:fix/ef-double-write-repository
Open

Fix EF double-write in InterviewSessionRepository#14
KhawarHabibKhan wants to merge 1 commit intoAzure-Samples:mainfrom
KhawarHabibKhan:fix/ef-double-write-repository

Conversation

@KhawarHabibKhan
Copy link

Fixes the double-write anti-pattern in InterviewSessionRepository where both ExecuteUpdateAsync and SaveChangesAsync are called on the same entity, causing two database round-trips and a race condition window for concurrent modifications.

Also fixes a related issue where the transcript StringBuilder logic produced leading whitespace/blank lines on the first update.

What Changed

  • Removed SaveChangesAsync() from UpdateInterviewSessionAsync and CompleteInterviewSessionAsync
  • Added EntityState.Detached after ExecuteUpdateAsync to prevent stale tracked state
  • Replaced StringBuilder transcript concatenation with clean string interpolation
  • Removed unused System.Text import

@KhawarHabibKhan
Copy link
Author

@microsoft-github-policy-service agree

Copy link
Author

@KhawarHabibKhan KhawarHabibKhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please review the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant