Tuesday, April 03, 2007 10:03 AM
by
dodyg
A hole in LINQ to SQL
Andres posed the question "
Basically, there is no disconnected mode. You can create a context
and attach objects that you kept somewhere, telling the context if it
was added/deleted/modified.
This basically means that if you plan
to build a multi-tier application with ADO.NET Orcas in the middle
tier, you will need to hack your own change tracking mechanism in the
client, send the whole changeset, and apply it in the middle tier. From
this point of view, it's a huge step backwards, as that's something we
already have with DataSets today."Frans Bouma blow it out the water :
"The 'solution' Microsoft provides for this, which is also a problem of
Linq to Sql btw, is the following: you first have to attach to the
context/session object an entity object with the original values, then
pass the entity object with the new values and then
it can perform change tracking. Yes, of course, but where do you get
that entity object with the original values from? From the DB? oh no
sir, you can't do that, as it might be that the entity was changed in
between, and if the user would have seen THOSE values, the user might
not have altered the entity at all. You also don't get the entity from
the datasource control, so you have to store it yourself, in an
in-memory cache. Though what happens when you're on a webfarm with
load-balancing?
This starts to get really complicated, and you would easily forget the most important thing: why is it YOUR problem?.
Isn't this part of what we could call 'entity management' which should
be taken care of by the framework you're using? Wouldn't this be solved
properly if the entity object itself was smart enough to
have change tracking on board? Yes it would. That's why Andres is so
right with his remark and the rest isn't. Andres understands correctly
that the end user of the framework doesn't care nor shouldn't
care about change tracking and when to pull old values from some cache
just to make something simple work."
And they are right. Why the hell do you need to do the plumbing code to do Original Value / Changed value that is common in web and disconnected form scenario ? Data Set has it. Jeeez.