I have two tables, Parts
and Blob
.
db.Parts
Id name x y z partimageid
-----------------------------------
1 bolt 30 40 5 4
2 screw 33 4 6 null
db.Blob
Id content name
------------------------------
4 fsbfvb picture.png
How can I get a part detail with image content?
Currently I am doing like this:
public async Task<IHttpActionResult> GetPart(int id)
{
var result = from part in db.Parts
join image in db.Blob on part.PartImageId equals image.Id
where part.Id == id
select new { part, image.Content};
return Ok(result);
}
It's working, but if image is not there - part also coming as null. what am I doing wrong here?