Reputation: 1888
I create a database with the data(id) 8,5,1,9,2,3,4,5. Then i want to retrieve the data and store it in an array. Does anyone can help me? I am using C# and linq to SQL.
My code:
using(DatabaseDataContext db = new DatabaseDataContext())
{
var query = from p in db.table1
select p.id;
int[] myArray = new int[query];
}
Upvotes: 0
Views: 2254
Reputation: 9214
Just call an extension method ToArray()
:
var array = (from p in db.table1
select p.id).ToArray();
Upvotes: 4