DbContext doesn't update properties of objects

We have a global DataManager that holds and manages a single DbContext.

We bind all the objects of a table called File to a tree view.

return this.ArchiveContext.File.Where(f => f.parent_id == null).ToList<File>();

New items get updated with the data binding, which is great. Unfortunately, properties like the name don't.

We figured it's probably best to just update them every x seconds. We also found out that, unless the context is recreated, none of the properties will get updated.

This is obviously the wrong approach.

What are the best practises when working with DbContext?

Answers


It is because you are using completely different array of objects when you use ToList() returning from your static dbcontext. Assuming you show your array of objects in a List or something like List. You may set DataSource property with newly allocated object, and it will refresh all your list.

listBox1.DataSource = null;
listBox1.DataSource = NewList;

Need Your Help

TransactionScope() in Sql Azure

transactionscope azure-sql-database

Does Sql Azure support using TransactionScope() when performing inserts? Below is a code snippet of what I am trying to do.

Cannot setup floating action buttons as class cannot be found (Android Studio)

android

So I am pretty new to android and I am trying to setup a floating action button with the Android Design Support Library using this guide in Android Studio.