In our app we use the SqlBulkCopy
class to facilitate bulk loading of our database. Recently, I've tried to add Glimpse to our solution but the code fails with an invalid cast:
System.InvalidCastException: Unable to cast object of type 'Glimpse.Ado.AlternateType.GlimpseDbConnection' to type 'System.Data.SqlClient.SqlConnection'
This is because Glimpse ADO is using a wrapped SqlConnection
to make its magic possible. Unfortunately, SqlBulkCopy
requires a SqlConnection
so I need to cast the DbConnection
.
Is there no out-of-the-box way to profile bulk insertions? The only work-around I came across with so far is:
(SqlConnection)((GlimpseDbConnection)dbConnection).InnerConnection
It's ugly since it requires referencing GlimpseDbConnection explicitly and probably it also requires adding custom time-line events to get some tracing. Is there no Glimpse add-on that solves this?