I am converting an existing application and I am using the existing database structure.
This is the model of the data I am querying:
public partial class StaffNotes
{
public int RecordNumber { get; set; }
public double? ContactNumber { get; set; }
public double? WriteNumber { get; set; }
public double? ToStaff { get; set; }
public double? FromStaff { get; set; }
public string Note { get; set; }
public DateTime? CriticalDate { get; set; }
public DateTime? NoteDate { get; set; }
public int? TicketNumber { get; set; }
public bool Imp { get; set; }
}
Instead of displaying the number of the ToStaff, I would like to display the appropriate name.
I have written the following query:
var staffNotes = _context.StaffNotes.FromSql("Select s.record_number, s.contact_number, s.To_Staff, s.From_Staff, s.Note_Date, s.Ticket_Number, s.Imp, s.Critical_Date, S.Note, s.write_number, c.first_name, c.last_name from staffnotes s, contacts c where s.contact_number = c.contact_number and s.Contact_Number = " + id).ToList();
My code runs and I'm not getting any errors. The only issue is the first_name
and last_name
do not appear in the data.
Is this because it is not part of the model? Is there a way to get around this?