I have a list that contains some ID's, and I'd want to pick the records whose ID is in that list. So far I have
var ids = new List<long> {1, 2, 3}; // Actually the list is not hard coded
using(var context = new MyContext())
{
context.MyModel.Database.SqlQuery("SELECT * FROM dbo.MyModel WHERE Id IN @p0", ids).ToList();
}
But this doesn't work, and it gives me an MySql.Data.MySqlClient.MySqlException
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '_binary 'System.Collections.Generic.List`1[System.Int64]' ' at line 1
Please don't give me a LINQ solution. Thanks in advance.