i want to assign the linq result to a multidimensional array and the below is my code, can any one tell me what i am doing wrong.
var query = (from b in db.FourBodyImages
where b.Status == true
orderby b.CreaedDate descending
select new { b.BodyImage, b.Description, b.HeaderName }
).Take(4).ToArray();
if(query.Count()>0)
{
string[,,] x = new string[4, 4,4];
x[,,] = query;
for (int i = 0; i < query.Length; i++)
{
if (i == 0)
{
imgBody1.ImageUrl = "FourBodyImages/" + x[0,0,0].ToString();
}
if (i == 1)
{
imgBody2.ImageUrl = "FourBodyImages/" + x[1,1,1].ToString();
}
if (i == 2)
{
imgBody3.ImageUrl = "FourBodyImages/" + x[2,2,2].ToString();
}
if (i == 3)
{
imgBody4.ImageUrl = "FourBodyImages/" + x[3,3,3].ToString();
}
}
}
If you just need to get 4 objects from the database, and then use them to fill 4 images, all you need to do is: