Note that there are some explanatory texts on larger screens.

plurals
  1. POLinq to SQL - Dirty Reads after Updating - WCF Service
    text
    copied!<p>I have a dbml file (linq to sql) to connect to my database. I have a manager that uses a generic repository (for each entity) to talk to the dbml. A manager uses the Repo to do work (CRUD operations). A WCF wraps the manager and exposes the it to the outside world (so my application can use it).</p> <p>DB &lt;--> IRepository&lt; Entity, DataContext> &lt;--> IManager(IRepo, IRepo...) &lt;--> WCFService(IManager)</p> <p>I've tested the manager, it works fine every time. The problem is the WCF. I'll read data (e.g. GetAllLocations), update the data (e.g. change a Location name), but then at some random point later, I'll read dirty data. E.g. if I've been changing a location name to from "BC 1", to "BC 2", to "BC 3", sometimes I'll read it and get older values. Like after I've changed it to "BC 3" and I am expecting to read "BC 3", I get "BC 1" (which doesn't make sense since the value before the update was "BC 2" anyway). WCF does not have caching by default, so why is this happening on my WCF and NOT on my manager? All the WCF does is pass values to the manager and get values from the manager, it's a very basic wrapper class.</p> <p>NOTE: I am using StructureMap to automatically resolve DependencyInjection and IoC stuff.</p> <p>Problem methods: anything that's reading (e.g. GetLocationById and GetAllLocations). They just don't always return the latest data from the database. I know it's not the manager because I created a simple project to test both the Manager and WCF independently, and only the WCF had dirty reads <strong>after updating data</strong> (specifically the Location). I have not testing all the other entities yet.</p> <p>One final note: I kept getting the "System.Data.Linq.ChangeConflictException: Row not found or changed." exception. I changed the DBML designer Location Entity's properties (except the PK) to Update Check: Never. The dirty reads were happening before this change anyway and the manager works fine (and it uses the DBML). So I have no reason to believe this is causing the dirty reads.</p> <p>Also, the Location Entity has a trigger in the database, but I'm eliminated this as the cause because I disabled it and that didn't help, and once again, the manager works fine.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload