简体   繁体   中英

Updating front-end WPF app from a SQL Server database

Please, help me clear my mind on the following question.

Recently I asked a question on SO, about possibility of immediate updating WPF classes from SQL Server DB through LINQ to SQL:

How to use PropertyChangedEventHandler of LINQ to SQL class for immediate updating?

from the answers I got know that this is rather complex issue and there is no easy way to know when and what exactly was changed in DB. The most common way is constant polling DB using a timer. (In answers were other ways of solving this issue but as workaround solutions, not always evident for developer).

My question is (and I think this scenario is common to most of DB connected applications):

Imagine I have a table in a DB with 50'000 or 100'000 records from which I get a query.

Using this query I should constantly update some visualization controls in my WPF app. So, does it mean that I should constantly make a query on this total number of records looking for one of them possibly changed (not just listening to some events about possible updating)? Is it common way to do this sort of things? Or maybe it is not a problem at all and such number of records is queried in milliseconds usually?

You can include a timestamp field in your records, and create a trigger in the SQL server to update that timestamp on update or insert. In your refresh code, query the table for records with timestamp greater than the last refresh time.

There is no way to have a database notify an application that does not involve some complicated communication between database and application. However application can easily notify each other that there has been a change you could use WCF to communicate between applications. Are you talking about a single application or several application that use the database?

What is your specific scenario? Are you concerned about concurrency?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM