Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dapper Parameter Length

Not sure if this is related to Dapper use or not. On a SQL Server where Dapper is use, I see multiple cached plans being generated with the only difference being the length of parameter:

(@parentId uniqueidentifier,@childName nvarchar(60)) 
 SELECT [ID] FROM [Items] WHERE [ParentID] = @parentId AND [Name] = @childName

(@parentId uniqueidentifier,@childName nvarchar(91))
SELECT [ID] FROM [Items] WHERE [ParentID] = @parentId AND [Name] = @childName

(@parentId uniqueidentifier,@childName nvarchar(15))
 SELECT [ID] FROM [Items] WHERE [ParentID] = @parentId AND [Name] = @childName

Are there any Dapper config settings which control parameter length? Can it be set to a fixed length nvarchar(256) matching the table column definition?

like image 665
Chad Miller Avatar asked Mar 07 '23 22:03

Chad Miller


1 Answers

You could define length when passing argument:

new {childName = new DbString { Value = "SomeValue", Length = 256, 
                               IsAnsi = false, IsFixedLength = false }};
like image 93
Lukasz Szozda Avatar answered Mar 29 '23 23:03

Lukasz Szozda