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?
You could define length when passing argument:
new {childName = new DbString { Value = "SomeValue", Length = 256,
IsAnsi = false, IsFixedLength = false }};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With