I have,
var car = db.QuerySingle("SELECT * FROM Stock WHERE Id = @0", carId);
The table “Stock” has image data columns ImgF1, ImgF2, …, ImgF12.
Now I want to retrieve those images as shown below
<ul>
@for(int i = 1; i < 12; i++){
var imageName = "ImgF" + i;
if(car.@imageName != null){
<li>
<img class="small_image" alt="image" src="@Href("~/Cars/XSThumbnail",carId, new{index = i})">
</li>
}else{
}
}
The problem is that car.@imageName or car.imageName don’t work as imageName is not the column name but just a variable for column names.
So please, if you have any ideas i’ll be grateful !!
Under the hood the
QuerySinglemethod returns a DynamicRecord instance what you can index with the column name: