I'm faced with a little problem. The situation is:
I have a MSSQL table which contains IDs
(int, identity, primarykey), and names
(string).
This table is huge, so i don't want to fill the entire dataset just for one LINQ-query.
I have a search algorithm, which fills a List<int>
with more than one ID.
I want to load the matching rows in a datagridview with the following code:
dataGridView1.DataSource = tbl_WorklistTableAdapter.GetDataByID(ids_here);
But i can't handle multiple IDs, just a single. The GetDataByID()
code needs to be this (i think):
SELECT [ID]
,[NAME]
FROM [DataBase].[dbo].[tbl_Namelist]
WHERE ID IN (@searchterm)
However WHERE ID IN
accepts comma-separated ints, like 1,2,3
. But the @variable is just one int.
How should i convert string to ints?
Thank you, and sorry for bad eng. :)