SqlMapper.AddTypeHandler doesnt reset internal deserializer cache
@mgravell is already working on this.
Since Nov 26, 2017.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
If you run a query for a given type e.g.
connection.Query<Foo>("select * from Foo where Id = @id", new {id });
the Foo type will get cached in SqlMapper._queryCache and along with it the deserizlier for Foo.
If you then were to add a TypeHandler for one of the properties on Foo e.g.
SqlMapper.AddTypeHandler(new FooPropertyTypeHandler());
The SqlMapper._queryCache cache for Foo type is not busted. So next time you go to run your Foo query as shown above it will not use the new type you just registered.
While it is odd to register a type handler after querying the type, it seems like a bug that the cache doesn't get busted.
I found this out because I was registering my type handlers in a static constructor for the class. I then re-read how static constructors work and have since changed my approach.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.