Custom Type Handler for List<int> To catch empty lists to avoid Full Table Scan
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
Any tips on adding Custom Type Handler for List to catch null or empty lists and throw exception. Getting lot of timeouts because of these empty lists. I tried doing it like this
public class EmptyListTypeHandler<T> : SqlMapper.TypeHandler<List<T>>
{
public override void SetValue(IDbDataParameter parameter, List<T> value)
{
if (value?.Any() == false)
{
throw new ArgumentException("List cannot be empty");
}
parameter.Value = value;
}
public override List<T> Parse(object value) => (List<T>)value;
}
But keeps on getting errors for "IN" clause.
Any tips? TIA
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 supplied EmptyListTypeHandler and Dapper's handling of List parameters in an IN clause. Reproduce the null and empty-list cases and inspect the resulting errors. Done would require an agreed behavior and coverage for rejecting empty lists without breaking normal IN-clause expansion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100