本文整理汇总了C#中LinqToTwitter.List.Batch方法的典型用法代码示例。如果您正苦于以下问题:C# List.Batch方法的具体用法?C# List.Batch怎么用?C# List.Batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinqToTwitter.List
的用法示例。
在下文中一共展示了List.Batch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QueryAccounts
private List<Domain.Model.Account> QueryAccounts(TwitterContext twitterctx, List<string> Ids)
{
List<Domain.Model.Account> response = new List<Domain.Model.Account>();
foreach (var batch in Ids.Batch(100))
{
var lookupQuery = string.Join(",", batch);
var relationships =
(from friendship in twitterctx.Friendship
where friendship.Type == FriendshipType.Lookup &&
friendship.UserID == lookupQuery
select friendship).SingleOrDefault().Relationships;
var users =
(from user in twitterctx.User
where user.Type == UserType.Lookup &&
user.UserID == lookupQuery
select user).ToList();
var joinedUserData =
(from user in users
join rel in relationships
on user.Identifier.ID equals rel.ID
select new Domain.Model.Account()
{
AccountId = ulong.Parse(user.Identifier.ID),
AccountName = user.Identifier.ScreenName,
AccountDescription = user.Description,
IsFollower = rel.Connections.Contains("followed_by"),
IFollow = rel.Connections.Contains("following"),
ProfileImage = new Uri(user.ProfileImageUrl ?? "http://127.0.0.1")
}).ToList();
response.AddRange(joinedUserData);
}
return response;
}