I am using Entity Framework 4.0 and I want to use the following query:
To do that I do the following:
strSQLQuery = "select * from MyTable where IDData IN (@IDs)";
lstParameters.Clear();
myParameter = new SqlParameter("@IDs", strIDs);
lstParameters.Add(myParameter);
myContext.MyTable.SqlQuery(strSQLQuery, lstParameters.ToArray<object>()).ToList<MyTable>();
But I get an exception that say that it is not possible to convert nvarchar
to bigint
.
That is because the parameter is the type string, and the IDs in the table are bigint
.
I try to create a list of long and add some IDs, but I get other error.
How can I use a list o IDs as parameter in a query?
I would like to use parameters, if that is possible.
Thanks.
See Question&Answers more detail:os