jonwagner / Insight.Database

Fast, lightweight .NET micro-ORM
Other
861 stars 145 forks source link

Add support for parameter type mapping when the type is an IEnumerable #387

Closed ghost1face closed 6 years ago

ghost1face commented 6 years ago

Description

Add support for parameter type mapping when the type is an IEnumerable. This is associated to a previous pull request I made a few months ago: #351. I've just discovered that this does not support IEnumerable types for example:

conn.QueryAsync<MyType>("SELECT * FROM dbo.MyType WHERE Id IN (@ids)", new { Ids = new[] { "a", "b", "c" });

A similar query today has been causing bad query plans due to mismatching data types. The Id column in MyTable is of type varchar but by default the parameters are created as nvarchar. This will address this issue and allow the custom type mapper to map nvarchar to varchar when it's an IEnumerable type.

Checklist

Please make sure your pull request fulfills the following requirements:

Type

This pull request includes what type of changes?

Breaking Changes

Does this pull request introduce any breaking changes?