Paz*_*man 2 c# group-by azure azure-table-storage
我在下面的linq查询中收到错误消息"不支持方法'join':
tableServiceContext = new CustomTableServiceContext(storageAccount.TableEndpoint.AbsoluteUri, storageAccount.Credentials);
tableServiceContext.RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(1));
var results = (from c in tableServiceContext.CreateQuery<ChannelEntry>("Channels").AsTableServiceQuery<ChannelEntry>()
join v in tableServiceContext.CreateQuery<VideoEntry>("Videos").AsTableServiceQuery<VideoEntry>() on c.PartitionKey equals v.ChannelID
join h in tableServiceContext.CreateQuery<HitEntry>("Hits").AsTableServiceQuery<HitEntry>() on v.PartitionKey equals h.VideoID
where c.RowKey.Equals(UserID)
group h by h.RowKey into g
select new BiggestFan { UserID = g.Key, Hits = g.Count() }).AsTableServiceQuery().Execute().OrderByDescending(b => b.Hits).Take(1);
Run Code Online (Sandbox Code Playgroud)
如果在此上下文中不支持"join",那么执行查询的最有效方法是什么?
我有频道,由视频组成,而视频又有Hits.我正在尝试找到当前登录用户的最大粉丝(最高点击率).
在不使用连接的情况下,这种类型的最有效方法是什么?我是否必须获取所有频道然后视频,然后点击3个单独调用表存储然后再进行连接?
是的,你不能加入.你有两个选择.
1)多次扫描 - 在加入之前拍一些.ToArray()语句,以便它在应用程序的内存中进行连接.这不是高性能,但表存储非常快.真的归结为这将导致多少行.
2)对表进行非规范化,以便在单个表中引用所需的所有键.这将使您在1个查询中获得结果,但意味着需要更新所有插入/更新逻辑.
| 归档时间: |
|
| 查看次数: |
4404 次 |
| 最近记录: |