I need to know if a new record has been added to a particular table in my windows application. Table might be manipulated by different applications.
For now I'm using a Timer control and querying to see if there is a new record (I add record content somewhere in my application and delete record to avoid getting duplicate record), but of course this is not a clean way for this purpose.
Is there something like an event or something better than my approach?
I'm using entity framework 6
Update : I've read about SqlDependency but I don't know if it can be implemented using entity framework
您可以尝试Linq2Cache尝试利用SqlDependency,这是我上次听说EF6已清理其行为 ,现在制定了与Query Notifications兼容的查询 。
Here's an existing StackOverflow article about that using the SQLDependency class .
Alternatively, you can cache the last record ID in memory/local to your program (in a file) or write the last processed record ID to a database table and search for anything more recent than that.
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.