Clearing the cache of a LINQ to SQL DataContext
VB.net:
Dim FLAGS As New Reflection.BindingFlags
FLAGS = Reflection.BindingFlags.Instance Or Reflection.BindingFlags.Public Or Reflection.BindingFlags.NonPublic
Dim meth As Reflection.MethodInfo
meth = db.GetType().GetMethod(“ClearCache", FLAGS)
meth.Invoke(db, Nothing)
C#:
public static void ClearCache(this ProjectSupportContext context){
const BindingFlags FLAGS = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
var method = context.GetType().GetMethod(“ClearCache", FLAGS);
method.Invoke(context, null);
}
ref:
http://blog.robustsoftware.co.uk/2008/11/clearing-cache-of-linq-to-sql.html