-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
detect all DynamicParameters scenarios; suppress parameter warnings (…
…also suppress DapperAOT enable advice if actively opted out)
- Loading branch information
Showing
7 changed files
with
95 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
test/Dapper.AOT.Test/Interceptors/DynamicParameters.input.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Data; | ||
using Dapper; | ||
using Microsoft.Data.SqlClient; | ||
[DapperAot(false)] | ||
internal class DynamicParametersTest | ||
{ | ||
private SqlConnection connection; | ||
|
||
static readonly DateTime From = new DateTime(2023, 6, 1), To = new DateTime(2023, 6, 30); | ||
public void UseTrivialDynamicParameters() | ||
{ | ||
var parameters = new DynamicParameters(); | ||
parameters.Add("@StartDate", From); | ||
parameters.Add("@EndDate", To); | ||
|
||
connection.Execute("insert Reservations ([Start], [End]) values (@StartDate, @EndDate)", parameters); | ||
connection.Execute("insert Reservations ([Start], [End]) values (@StartDate, @EndDate)", (SqlMapper.IDynamicParameters)parameters); | ||
connection.Execute("insert Reservations ([Start], [End]) values (@StartDate, @EndDate)", new Foo()); | ||
} | ||
public void UseAnonType() | ||
{ | ||
var parameters = new | ||
{ | ||
StartDate = From, | ||
EndDate = To, | ||
}; | ||
|
||
connection.Execute("insert Reservations ([Start], [End]) values (@StartDate, @EndDate)", parameters); | ||
} | ||
class Foo : SqlMapper.IDynamicParameters | ||
{ | ||
void SqlMapper.IDynamicParameters.AddParameters(IDbCommand command, SqlMapper.Identity identity) { } | ||
} | ||
} |