1

I'm trying to develop a multi-user application that basically would have a list of some items. Each user is doing some CRUD operations to this list. I need that users see changes to list when other users make some changes.

I thought binding is what I need, but according to information in msdn, DbContext is a Unit of Work/Repository... does this mean that it is not possible for DbContext to read updates from data base automatically?

http://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext(v=vs.103).aspx

Is there a way to get the desired result using Entity Framework?

[EDIT] Is the only way to get updates from database is to use timer with additional code to reload data from database? Is this the only option for real-time apps?

Prokurors
  • 2,458
  • 3
  • 40
  • 65
  • Depends on how multi-user your multi-user application is. There [are some options](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldependency.aspx) but it [may not scale well](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldependency.aspx#alert_note) to over a few concurrent users. – Scott Chamberlain Oct 21 '13 at 23:22
  • @ScottChamberlain Suppose this is an application for call center - some users register user calls->works in to the list and other users are pulling those works -> assigning who will work with those works. User A needs to know, that user B has already pulled work from unassigend work list. What is the best option to do accomplish this? Use a timer and refresh data from database after each X seconds? – Prokurors Oct 22 '13 at 10:22

1 Answers1

1

DataBinding means a binding between UI and your Objects and not Objects to DataBase.

You need to call a Reload/Refresh method to get the latest database values. Like this: http://stackoverflow.com/questions/16872305/i-do-not-understand-how-ef5-dbcontext-entryentity-reload-method-is-supposed

(See comments)

Rand Random
  • 7,300
  • 10
  • 40
  • 88
  • Suppose this is an application for call center - some users register user calls->works in to the list and other users are pulling those works -> assigning who will work with those works. User A needs to know, that user B has already pulled work from unassigend work list. What is the best option to do accomplish this? Use a timer and refresh data from database after each X seconds? – Prokurors Oct 22 '13 at 10:29
  • 1
    Normally such a scenario is done with push notifications, to minimize the timer overhead when nothing happens. I would implement such a push notification with TCP pakets and listeners on the other side. This can be done with any network protokol, you just need a sender and a listener. You can also have a look at Firebird Database they have something called Server events. http://www.firebirdsql.org/file/documentation/papers_presentations/Power_Firebird_events.pdf (thats the first google link, maybe you find something more useful) – Rand Random Oct 22 '13 at 12:49
  • Hmmm... so maybe there could be a MS SQL trigger that stores an information about what should be refreshed and client app has a timer that checks this small change info table and when there is information about changes - then reloads data from database? You mention firebirdsql db server, but are there solutions that work on MS SQL db server? – Prokurors Oct 22 '13 at 13:33
  • 1
    It could be done with MSSQL trigger, but still the overhead stays when nothing is done and you do a timer which checks every x seconds. Just imagine your scenario with 200 users, having a timer that checks every 5 secs if something is new. This would result in 2400 queries every minute, and if there where no change in this minute you have 2400 useless queries because there was nothing to fetch. Instead of 1 TCP Packet send when there is actually something to send, I just mentioned firebird because it has those events build in (they are like tcp packets). I dont know of such a feature in MSSQL. – Rand Random Oct 22 '13 at 14:33
  • But its not hard to implement yourself, so if you arent familar with opensource databases and prever MSSQL just stick to it and do it your self. – Rand Random Oct 22 '13 at 14:34
  • Thanks for the helpful comments - I will mark Your answer (although the actual answer I think is in Your comments) – Prokurors Oct 22 '13 at 21:15
  • Glad to be of help, I added a simple "(See comments)" to my answer for future reference. – Rand Random Oct 23 '13 at 08:39