Ok, I have managed to get the following working
public IQueryable getTicketInformation(int ticketID)
{
var ticketDetails = from tickets in _context.ticke
This line is syntactically incorrect:
return ticketDetails.AsQueryable();
and should read
return ticketDetails.AsQueryable();
Also, you're creating anonymous objects with the select new {
, but you want to create myObject
instances. A correct implementation would look like this:
public IQueryable getTicketInformation(int ticketID)
{
return from tickets in _context.tickets
join file in _context.file_objects on tickets.ticket_id equals file.source_id
where tickets.ticket_id == ticketID
select new myObject() {
ticket_id = tickets.ticket_id,
title = tickets.title,
care_of_email = tickets.care_of_email,
filename = file.filename
};
}
The new SomeClass() { Property = value, ...
syntax creates a SomeClass
instance and sets the properties to the given values. Alternatively you could implement a constructor on the myObject
class and call it in the linq statement with select new myObject(...)
.