内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用
我有一个列表,上面有我的UserProfile的id表
。我如何选择UserProfiles
?
var idList = new int[1, 2, 3, 4, 5]; var userProfiles = _dataContext.UserProfile.Where(......);
如何用linq实现?
Where和.Contors的解具有O(N平方)的复杂性。简单.join应该有更好的性能(由于散列而接近O(N))。正确的代码是:
_dataContext.UserProfile.Join(idList, up => up.ID, id => id, (up, id) => up);
请看下面的测试示例:
private static void Main(string[] args) { var userProfiles = GenerateUserProfiles(); var idList = GenerateIds(); var stopWatch = new Stopwatch(); stopWatch.Start(); userProfiles.Join(idList, up => up.ID, id => id, (up, id) => up).ToArray(); Console.WriteLine("Elapsed .Join time: {0}", stopWatch.Elapsed); stopWatch.Restart(); userProfiles.Where(up => idList.Contains(up.ID)).ToArray(); Console.WriteLine("Elapsed .Where .Contains time: {0}", stopWatch.Elapsed); Console.ReadLine(); } private static IEnumerable<int> GenerateIds() { // var result = new List<int>(); for (int i = 100000; i > 0; i--) { yield return i; } } private static IEnumerable<UserProfile> GenerateUserProfiles() { for (int i = 0; i < 100000; i++) { yield return new UserProfile {ID = i}; } }
控制台输出:
Elapsed .Join time: 00:00:00.0322546
Elapsed .Where .Contains time: 00:02:19.4072107
目前呼叫中心只有API文档,需要用户自己开发。如果用户需要saas系统的呼叫中心可以使用智能外呼机器人:https://cloud.tencent.com/product/ccsr
你有没有调整观众端表现,即通过对 LivePushConfig 中的homeOrientation设置项进行配置,它控制的是观众端看到的视频宽高比是16:9还是6:19,调整后的结果可以用播放器查看以确认是否符合预期。
控制台使用的是新的接口,批量创建子网,https://cloud.tencent.com/document/product/215/31960,可以指定路由表。terraform开发的时候是基于api2.0开发的,还没有这个接口,因此暂时无法使用