I have a pretty big table where I want to get certain rows by Id. To save data I need to send a list of Ids, which can be up to a few thousands. I’ve tried the way to send the ids by commaseperated string to a stored procedure, but to convert the string back to a selectable list took a few minutes.
Now I’ve tried with Contains on a view, but I always get an error, that I used too many parameters.
Is there a best practice way to solve my problem? Thanks in advance – hope you know what I mean.
With direct C# and SQL, you can use table value parameters – it’s a way to pass an in memory table to a sproc.
http://msdn.microsoft.com/en-us/library/bb675163.aspx
I don’t believe Linq supports it. But, I found this article concerning using TVPs via Linq with a workaround (haven’t tried it):
http://blog.mikecouturier.com/2010/01/sql-2008-tvp-table-valued-parameters.html
Hope that helps.