C# 需要ASP.NET Core上Linq中联接表的帮助吗
基本上我是在ASP.NET内核上工作的,我有一个FromSqlRaw语句,它过滤并将一些ID保存在一个talbe(ActiveCalls)值中。 然后使用Linq过滤另一个数据库表(AppUsers)。 我的目标是使用我从ActiveCalls获取的ID保留Appusers的所有列 带有Ids结果的SqlRaw代码:(13)正确C# 需要ASP.NET Core上Linq中联接表的帮助吗,c#,asp.net,linq,C#,Asp.net,Linq,基本上我是在ASP.NET内核上工作的,我有一个FromSqlRaw语句,它过滤并将一些ID保存在一个talbe(ActiveCalls)值中。 然后使用Linq过滤另一个数据库表(AppUsers)。 我的目标是使用我从ActiveCalls获取的ID保留Appusers的所有列 带有Ids结果的SqlRaw代码:(13)正确 我必须使用Linq和这3个步骤得到结果,而不是将所有内容都合并到Sql查询中在这种情况下,我不想使用SQLRAW中的 var结果= 从ac in_context.Act
我必须使用Linq和这3个步骤得到结果,而不是将所有内容都合并到Sql查询中在这种情况下,我不想使用SQLRAW中的
var结果=
从ac in_context.ActiveCalls
其中ac.TimeReceived>DateTime.Parse(“2021-01-01”)
&&ac.GeoX>23.8097593342164
&&ac.GeoX<23.8838031312548
&&ac.GeoY>38.1026672246045
&&ac.GeoY<38.1607577524088
选择ac.web\u userid;
results=results.Distinct();
var appusers=_context.appusers.AsQueryable();
appusers=appusers.Where(s=>s.LastCall>=start&&s.LastCall尝试类似的操作
var results = _context.ActiveCalls.FromSqlRaw("SELECT web_userid from ActiveCalls where TimeReceived>'2021-01-01' and GeoX >
23.8097593342164 and GeoX < 23.8838031312548 and GeoY > 38.1026672246045 and GeoY < 38.1607577524088 group by web_userid");
appusers = appusers.Where(s => s.LastCall >= start && s.LastCall <= end && results.web_userid.contains(s.Id));
var results=\u context.ActiveCalls.FromSqlRaw(“从ActiveCalls中选择web\u userid,其中TimeReceived>'2021-01-01'和GeoX>
23.8097593342164和GeoX<23.8838031312548和GeoY>38.1026672246045和GeoY<38.1607577524088(按web用户ID分组);
appusers=appusers.Where(s=>s.LastCall>=start&&s.LastCall)我不太明白。要在一个链接短语中总结这三个步骤吗?
appusers = appusers.Where(s => s.LastCall >= start && s.LastCall <= end);
appusers = from res in results
join ap in appusers
on res.web_userid equals ap.Id
select ap;
var results = _context.ActiveCalls.FromSqlRaw("SELECT web_userid from ActiveCalls where TimeReceived>'2021-01-01' and GeoX >
23.8097593342164 and GeoX < 23.8838031312548 and GeoY > 38.1026672246045 and GeoY < 38.1607577524088 group by web_userid");
appusers = appusers.Where(s => s.LastCall >= start && s.LastCall <= end && results.web_userid.contains(s.Id));