Hi folks,
I am using Asp.net 5 with Web api.
Here is my sample code:
Models Class:
public class Student { public int StuId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } // Foreign Key (SchoolID) public int SchoolId { get; set; } public School School { get; set; } } public class School { public int SchoolId { get; set; } public string SchoolName { get; set; } public int Fee { get; set; } public virtual ICollection<Student> Students { get; set; } }
Api Controller:
[HttpGet] public IEnumerable<Student> GetStudents() { return _context.Students; } [HttpGet("{id}", Name = "GetStudent")] public IActionResult GetStudent([FromRoute] int id) { Student student = _context.Students.Single(m => m.StuId == id); return Ok(interview); }
I am getting only query student. How to get all two queries table as student with school if one to many?
I am waiting for your response.
Thanks