markrendle/Simple.Data — Issue #148: "Like" does not work due to parameter's length
Author: bmatte
Created: 2012-02-13 13:11:44+00:00
State: open

given the following table and data (SQL Server):

CREATE TABLE [dbo].[Pers] (
[Group] [char](6) NULL
)
INSERT INTO [dbo].[Pers]([Group])VALUES ('100004')
INSERT INTO [dbo].[Pers]([Group])VALUES ('200000')

this snippet does not find anything:
var per in db.dbo.Pers.FindAll(db.dbo.Pers.Grup.Like("%4"))

I've investigated with the SQL Server Profiler and I've found that the cause was the parameter's length equal to 6 instead of 2.
exec sp_executesql N'select [dbo].[Pers].[Group] from [dbo].[Pers] WHERE [dbo].[Pers].[Group] LIKE @p1',N'@p1 char(6)',@p1='%4 '