I'm still very new in my linq skills. I have a mysql query that returns 3 records, each record is an int. I want to stick those ints into an array. I thought I could make it easy on myself and do that with a linq command instead of creating a reader and looping through the results. Here is my code:
query = "SELECT cic.catid FROM cart_item ci LEFT JOIN cart_item_category cic USING (itemref) WHERE ci.pid = @pid";
try
{
item.catIDs = con.Query(query, new { pid = ImId}).ToArray();
}
catch(MySqlException ex)
{
}
I am getting the error: Cannot implicitly convert type 'dynamic[]' to 'int[]'
I'm assuming my linq query is not correct.
new int[] { pid = ImId }. You create a dynamic type when you donew { pid = ImId }or makeitem.catIDsadynamic[]