Array.Contains() conversion to Literal is not the best solution


To get the correct behavior of an SQL IN (a, b, c) when using Array.Contains(dbColumn), the Array expression is being converted to a literal so that the correct conversion to a comma-delimited string takes place. Not sure if this is the best solution to this.


kainhart wrote Jul 28, 2009 at 11:26 PM

A comma separated list is at least sounds better than the Linq to SQL implementation which is to use a separate parameter for each value. The problem with using a separate parameter (at least with SQL Server 2005+) is that there is a limit of 2100 parameters per stored procedure, and it is a stored procedure through which Linq to SQL executes the generated SQL command. See more information about this issue and my suggested fix on the Microsoft Connect site by following the link below.


wrote Feb 14, 2013 at 3:29 AM