这是SQL查询
select *
from Students
where StudentID in (select StudentID from FeeEntry);
我想在ASP中执行这个SQL查询。. NET Core MVC,不使用SQL查询命令或任何其他过程,也不使用SqlDataAdapter
.
我想要这个格式。
c#代码格式:
var myvalues = (from values in _context.students
where values.studentID in table2 // where studentID is the foreign key
select values).ToList();
你可以使用实体框架,你可以在这里找到信息:
- 在这里阅读实体框架。 在这里阅读LINQ to SQL。
那么你的代码看起来像这样:
var ids = _context.FeeEntry.Select(x => x.StudentID).tolist();
var myvalues = _context.students.where(x => ids.Contains(x.studentID)).toList();