This is the SQL query
select *
from Students
where StudentID in (select StudentID from FeeEntry);
I want to perform this SQL query in ASP.NET Core MVC without using SQL query command or any other procedure or with SqlDataAdapter
.
I want this format.
The format of C# code:
var myvalues = (from values in _context.students
where values.studentID in table2 // where studentID is the foreign key
select values).ToList();
CodePudding user response:
You can use Entity Framework, you can find information here:
Then your code would look like this:
var ids = _context.FeeEntry.Select(x => x.StudentID).tolist();
var myvalues = _context.students.where(x => ids.Contains(x.studentID)).toList();