I have WebAPI controller to generate xml from table data
here is code
public class XMLController : ApiController
{
private trackingappEntities db = new trackingappEntities();
[HttpGet]
public HttpResponseMessage Index()
{
var xdoc = new XDocument(
new XElement("data",
db.TimeTables.Select(w =>
new XElement("worker",
new XAttribute("id", w.INN),
new XElement("start", w.StartDay),
new XElement("pause", w.StartPause),
new XElement("continue", w.EndPause),
new XElement("end", w.EndDay)
)
)
)
);
return new HttpResponseMessage() { Content = new StringContent(xdoc.ToString(), Encoding.UTF8, "application/xml") };
}
}
Here is TimeTable class
public partial class TimeTable
{
public int Id { get; set; }
public string Company { get; set; }
public string INN { get; set; }
public string StartDay { get; set; }
public string StartPause { get; set; }
public string EndDay { get; set; }
public string EndPause { get; set; }
}
But when I send request, I have this response
Only parameterless constructors and initializers are supported in LINQ to Entities.
How I can fix this?