Customizing Dump in a DataContext package
Hi, I'm having an issue with the ToDump
function inside a DataContext package. I'm creating a static method as per documentation but it doesn't seem to be called and the output does not get formatted the way I want it to.
Example:
public sealed class MongoDriver : DynamicDataContextDriver { public static object ToDump(object input) { var document = input as BsonDocument; return document != null ? BsonTypeMapper.MapToDotNetValue(document) : input; } // unrelated code here }
Is there something I'm missing or is this a limitation of the DataContext?
Comments
static object ToDump(object input)
should be inProgram
context and not in class, (example).It should be member method in your case, (example).
The static
ToDump
method applies to scripts and My Extensions - not drivers.With drivers, you instead override the
PreprocessObjectToWrite
method. This is described in the documentation:https://www.linqpad.net/Extensibility.aspx
Oh, I see. Thank you, Joseph!
For those that might come after, I've achieved what I wanted with just a small modification of my code: