LINQ to SQL automatic updates

C

cyberdude

Hi,

I've discovered that if a new row is added to a database table (say via
ISQL), then the LINQ-to-SQL entity is automatically updated with this new
row. This is undoubtably a useful feature because you don't have to manually
refresh your entity. However it can also pose problems with tables that are
updating v.frequently - you might not want to update the in-memory entity
automatically.

How do you switch this feature off in LINQ-to-SQL ?
 
A

Anthony Jones

cyberdude said:
Hi,

I've discovered that if a new row is added to a database table (say via
ISQL), then the LINQ-to-SQL entity is automatically updated with this new
row. This is undoubtably a useful feature because you don't have to
manually refresh your entity. However it can also pose problems with
tables that are updating v.frequently - you might not want to update the
in-memory entity automatically.

How do you switch this feature off in LINQ-to-SQL ?

How did you make this discovery? I find it highly unlikely.
 
S

Steven Wilmot

I've discovered that if a new row is added to a database table (say via
ISQL), then the LINQ-to-SQL entity is automatically updated with this new
row. This is undoubtably a useful feature because you don't have to
manually refresh your entity. However it can also pose problems with
tables that are updating v.frequently - you might not want to update the
in-memory entity automatically.
How did you make this discovery? I find it highly unlikely.

LINQ does not store data - It merely retains an "Expression-Tree" .

When you ask the the "Results" of the expression, LINQ will translate the
expression-tree into a SQL statement, and actualy retrieve the results from
the database.

So, all that is happening is that when you requests the results a second
time, you are just evaluating the "SELECT statement" a second time (which
will then match the new row.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top