Click here to Skip to main content
15,891,837 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionForce entity framework to load new data from database without disposing the context Pin
desanti2-Apr-19 3:21
desanti2-Apr-19 3:21 
AnswerRe: Force entity framework to load new data from database without disposing the context Pin
Dave Kreskowiak2-Apr-19 4:23
mveDave Kreskowiak2-Apr-19 4:23 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
desanti2-Apr-19 7:40
desanti2-Apr-19 7:40 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
Dave Kreskowiak2-Apr-19 9:11
mveDave Kreskowiak2-Apr-19 9:11 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
desanti2-Apr-19 9:22
desanti2-Apr-19 9:22 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
Dave Kreskowiak2-Apr-19 11:24
mveDave Kreskowiak2-Apr-19 11:24 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
desanti3-Apr-19 5:01
desanti3-Apr-19 5:01 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
Dave Kreskowiak3-Apr-19 7:22
mveDave Kreskowiak3-Apr-19 7:22 
Those changes are NOT known by EF. At least not until you run a query again to retrieve the entire set of records again. But now you have a problem. How does EF know that the records are deleted? It doesn't. The records just don't show up in the result set from the database. That in no way means that they were deleted. The only way to know that would be to get the record ID of what EF has cached and try to retrieve that record ID from the database. Now do that for every record you have cached and it'll take a long time.

Move on to the problem of just telling EF to reload a specific table. Great, you now have all of the data from that table, but how to do handle the case where the cached data is "dirty"? That means you have data in the cache that's been modified but not written back tot he database. Do you through those changes out in favor of the current data? Do you skip that changes? Do you modify only certain fields? How is the ORM supposed to know which fields to keep and which to throw out and refresh?

Another problem. What query returned the data the generated the object in the cache? There is ORM that I'm aware of that caches the query that generated a set of object graphs. What if there's multiple queries that can be run that generate a particular object in a graph? How do you know which query to run to PROPERLY regenerate that object with the correct data? It's impossible for the ORM to know that.

Google "database concurrency" for the difficulties in doing what you want to do. There is no easy solution to this problem, and not every solution is going to work for every application.

You're looking at this through the lens of what you want EF to do and not from the standpoint of how any ORM would even accomplish this in a generic way usable by all applications. I know you just want to call .Reload() and have it work, but you're not seeing the complexity behind actually making that happen.

GeneralRe: Force entity framework to load new data from database without disposing the context Pin
desanti3-Apr-19 8:23
desanti3-Apr-19 8:23 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
Dave Kreskowiak3-Apr-19 8:57
mveDave Kreskowiak3-Apr-19 8:57 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
desanti3-Apr-19 9:40
desanti3-Apr-19 9:40 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
Dave Kreskowiak3-Apr-19 10:30
mveDave Kreskowiak3-Apr-19 10:30 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
desanti3-Apr-19 11:16
desanti3-Apr-19 11:16 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
desanti4-Apr-19 0:41
desanti4-Apr-19 0:41 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
Dave Kreskowiak4-Apr-19 5:49
mveDave Kreskowiak4-Apr-19 5:49 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
desanti4-Apr-19 6:18
desanti4-Apr-19 6:18 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
Dave Kreskowiak4-Apr-19 9:22
mveDave Kreskowiak4-Apr-19 9:22 
Questioni want to import a text file to datatable or something like that Pin
Member 142077921-Apr-19 4:41
Member 142077921-Apr-19 4:41 
AnswerRe: i want to import a text file to datatable or something like that Pin
David Mujica1-Apr-19 5:37
David Mujica1-Apr-19 5:37 
GeneralRe: i want to import a text file to datatable or something like that Pin
Member 142077921-Apr-19 21:10
Member 142077921-Apr-19 21:10 
AnswerRe: i want to import a text file to datatable or something like that Pin
Richard MacCutchan1-Apr-19 5:55
mveRichard MacCutchan1-Apr-19 5:55 
GeneralRe: i want to import a text file to datatable or something like that Pin
Member 142077921-Apr-19 21:08
Member 142077921-Apr-19 21:08 
GeneralRe: i want to import a text file to datatable or something like that Pin
Richard MacCutchan1-Apr-19 21:20
mveRichard MacCutchan1-Apr-19 21:20 
GeneralRe: i want to import a text file to datatable or something like that Pin
Member 142077921-Apr-19 21:23
Member 142077921-Apr-19 21:23 
GeneralMessage Removed Pin
1-Apr-19 21:45
Member 142077921-Apr-19 21:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.