score:54

Accepted answer

Instead of Take(1) which returns sequence IEnumerable<string>, use FirstOrDefault() which returns single string value (or null if there is no results). Also don't create anonymous type for subquery result:

imageName = (from soh in db.tblProductImages
             where soh.product_id == e.ProductId
             select soh.image_name).FirstOrDefault()

BTW FirstOrDefault() generates TOP(1) SQL.


Related Query

More Query from same tag