Custom ADO.NET provider to intercept and modify sql queries.
- by Faisal
Our client has an application that stores blobs in database which has now grown enough to impact the performance of SQL Server. To overcome this issue, we are planning to offload all blobs to file system and leave the path of file in a new column in user table.
Like if user has a table docs with columns id, name and content (blob); we would ask him to add a new column 'filepath' in this table.
Our client is willing to make this change in this database. But when it comes to changing the sql queries to read and write into this table, they are not ready to accep this. Actually, they don't want any change that results in recompilation and deployment.
Now we are planning to write a custom ADO.NET provider that will
intercept the select queries
add a column 'filepath' at the end of the select statement
retieve the result set and modify the 'content' column value based on 'filepath' value
Is there any use case that you think will certainly fail with this approach?
I know this sounds dirty but do we have a better way?