I am working on asp.net mvc 4 web api with EF code first model. I have a class with navigation property like like,
public class Branch
{
[Key]
public int Id{get; set;}
public List<book> books{get; set;}
}
and my book class is like,
public class book
{
[Key]
public int id{get; set;}
public string Name{get; set;}
}
Now i need to get list of branches so i write like,
public IQuerable<branch> GetBranches(int branchid)
{
return context.school.where(m=>m.id==branchid).ToList().AsQuerable();
}
now i want to assign some data to book property in branch class so did like,
context.school.ToList().ForEach(m=>m.books=GetBooks(branchid));
and now to get branch i have url like,
/api/branch/12
and is there any way to get particular book in a particular branch using url like
/api/branch/12/book/567
to return book number 567 in branch number 12. please guide me.