here is my table:
table name: data
fields:
- Id
- category
- description
- imagePath
I'm building a webApi that returns all imagePath or by id.
web api controller:
namespace task.Controllers
{
public class ImagesController : ApiController
{
DataEntry db = new DataEntry();
public IEnumerable<datum> GetImages()
{
var imagePath = from m in db.data select m;
return imagePath;
}
public IHttpActionResult GetImages(int id)
{
var imagePath = from m in db.data select m;
var imagPath = imagePath.Where((p) => p.Id == id);
if (imagePath == null)
{
return NotFound();
}
return Ok(imagePath);
}
}
}
It's returning all fields (Id,category, description and imagePath) instead of imagePath only.and for the select by Id method it's not working also, so what is wrong??