I created an Entity Framework app using NetCore 2.2. It's just a simple app that has models and controllers that were scaffolded from my database.
In my database, if I run this query, I will get the expected 4 rows of data back.
select * from BookSeries where mainBookID = 'akfj36hf'
In my controller, I'm trying to mimic the SQL above, with this code:
[HttpGet("BookSeriesByMain/{id}")]
public async Task<List<BookSeries>> GetBookSeries(string id)
{
return await _context.BookSeries.Where(n => n.MainBookId == id).ToListAsync();
}
When I hit the controller URL, with the same id of 'akfj36hf', it is returning EVERY row in the database for that table(BookSeries). Not just the expected 4 rows.
Here is my model:
public partial class BookSeries
{
public string BookLinkId { get; set; }
public string MainBookId { get; set; }
public string ChildBookId { get; set; }
public int? OrderId { get; set; }
public virtual BookList MainBook { get; set; }
}
I'm kind of at a loss as to what I did wrong.
Does anyone see anything that I messed up?
THanks!