I currently have a linq query to select 5 random rows from my products table. Once I have the collection in my model how do I access a specific row? I’m using First() to get at my first row but Im not sure what I would use if I wanted to get data from the 3rd row in that query.
Thanks!
var Model = (from r in DB.Products select r).OrderBy(r => Guid.NewGuid()).Take(5);
var ProductID1 = Model.First().ProductID;
var ProductID3 = Model.???
You should only run the query once and then iterate over the rows using foreach or just use the index property to select the appropriate product