Type handler with generic type
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
Hello,
For now, we can add type handler for class without generic type.
In our software, we need possibility to add a type handler for a generic type like this one =>
public class Ref<T> {...}
We think that there could be a delegate function which check if the given object can be assignable to the generic type when we add a type handler =>
SqlMapper.AddTypeHandler(t => t.IsAssignableTo(typeof(Ref)), new RefTypeHandler());
And to finish, the type handler methods should have the wanted type in parameter, so we can parse and set correctly =>
public sealed class RefTypeHandler : SqlMapper.TypeHandler<Ref>
{
public override void SetValue(IDbDataParameter parameter, Ref value, Type type)
{
throw new System.NotImplementedException();
}
public override Ref Parse(object value, Type type)
{
throw new System.NotImplementedException();
}
}
This is not an issue, but a new functionality, but I don't know where to write it, and it might be not relevant as well.
Just let me know !
Regards !
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.
Research direction
Start with the SqlMapper.AddTypeHandler entry point and the TypeHandler API described in the issue. Determine how generic type matching and the proposed type parameters should work, then define tests for registration, parsing, and setting values for Ref. Done means the feature has an agreed design and verified support for generic handlers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100