|
|
but it dosen't work. I don't know why. Enobody help me?
|
|
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jon BellamyPosted Jul 3, 2009, 7:48 AM
Igor ShtankoPosted Apr 8, 2010, 1:33 PM
This solution works fine and do not require recreating DataContext.
1. You need to reset internal Table
for this you need change private property cachedList of Table
You can use following utility code:
public static class LinqDataTableExtension
{
public static void ResetTableCache(this ITable table)
{
table.InternalSetNonPublicFieldValue("cachedList", null);
}
public static void ResetTableCache(this IListSource source)
{
source.InternalSetNonPublicFieldValue("cachedList", null);
}
public static void InternalSetNonPublicFieldValue(this object entity, string propertyName, object value)
{
if (entity == null)
throw new ArgumentNullException("entity");
if(string.IsNullOrEmpty(propertyName))
throw new ArgumentNullException("propertyName");
var type = entity.GetType();
var prop = type.GetField(propertyName, BindingFlags.NonPublic | BindingFlags.Instance);
if (prop != null)
prop.SetValue(entity, value);
// add any exception code here if property was not found :)
}
}
using something like:
var dSource = Db.GetTable(...)
dSource.ResetTableCache();
2. You need to reset your BindingSource using something like:
_BindingSource.DataSource = new List
Mateusz MisteckiPosted Jul 4, 2009, 11:55 AM
Niladri BiswasPosted Jun 7, 2009, 11:55 PM