Giocanni (13) [Avatar] Offline
#1
I'm still waiting for the book from amazon so I don't know if you treat about this in the book.

This is the situation:

AA opens his application, queries the db and reads the results in a gridview
BB meanwhile opens the same application, queries the db, and modify a record, then close

I've noticed that AA will continue querying with his datacontext (created at the start of the application so with the old data).

db.refresh() works, because refreshes the whole datacontext displaying the current values in the database

but putting a db.refresh in every query generate a performance problem

what are my options? I can't think of working in front of a table of data that is not updated...


thank you very much

EDIT: i CAN'T think of working with data not up to date..
jwooley (123) [Avatar] Offline
#2
Re: What kind of refresh options you suggest?
The object identity tracking implementation was put in place to keep the value an individual is maintaining in memory rather than the values from another user. The concurrency check occurs at the point of trying to submit the changes. At that point, a concurrency exception will be thrown. As we discuss in chapter 7, there are a number of options you have to manage the concurrency issues. LINQ to SQL follows the disconnected model of the rest of .Net.
Giocanni (13) [Avatar] Offline
#3
Re: What kind of refresh options you suggest?
yes, I already implemented the concurrency checks on updates
but if the .net system is based on the same principle, how does the .net applications deal with being aware of updates? I think that working on a cached table that is not updated would be a problem in every work situation


the thing that I find strange is that when I open the program (creating therefore all the new datacontext) is fast, but if I try to refresh all the datacontext, with something like

dim queryall = from s in db.Customers _
select s
db.refresh(keepchanges, queryall)


this line is slower than reopening the whole, updated program again. Of course I can just add the refresh line in the query that I absolutely need to be updated, but that's another matter...

Am I missing something, or all this is perfectly normal? is not possible to implement some observing pattern for changed values?
fabrice.marguerie (224) [Avatar] Offline
#4
Re: What kind of refresh options you suggest?
Instead of refreshing after each query, maybe you can use the SqlDependency class to determine when a refresh is needed. SqlDependency can notify you when data changes in the database.
See the following pages for hints on how to use this:
http://dunnry.com/blog/UsingSQLDependencyObjectsWithLINQ.aspx
http://www.thedatafarm.com/blog/2007/09/15/QueryNotificationsAndLINQToSQLWellIllBeYouCanDoItWithCaveats.aspx
Giocanni (13) [Avatar] Offline
#5
Re: What kind of refresh options you suggest?
thank you for your answer
this seems interesting indeed