本文整理汇总了C#中IRepository.GetAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.GetAsync方法的具体用法?C# IRepository.GetAsync怎么用?C# IRepository.GetAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRepository
的用法示例。
在下文中一共展示了IRepository.GetAsync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MostHashtaggedModule
public MostHashtaggedModule(IRepository<string, IEnumerable<Hashtag>> hashtags)
{
this.Get["/most-hashtagged/{track}", true] = async (parameters, __) =>
{
// see https://github.com/NancyFx/Nancy/issues/1154
var track = ((string)parameters.track).Replace("해시", "#");
var trackHashtags = (await hashtags.GetAsync(track)).ToList();
var entries = trackHashtags
.GroupBy(tweet => tweet.Text, StringComparer.InvariantCultureIgnoreCase)
.Select(g => new HashtagEntry
{
Text = g.Key,
Count = g.Count(),
})
.OrderByDescending(entry => entry.Count)
.Select((entry, index) =>
{
entry.Position = index + 1;
return entry;
})
.Take(10)
.ToList();
return new Leaderboard<HashtagEntry>
{
Entries = entries,
Count = trackHashtags.Count,
Since = trackHashtags.Any() ? trackHashtags.Min(hashtag => hashtag.HashtaggedAt) : (DateTime?)null,
LastActivityDateTime = trackHashtags.Any() ? trackHashtags.Max(hashtag => hashtag.HashtaggedAt) : (DateTime?)null,
};
};
}
示例2: MostMentionedModule
public MostMentionedModule(IRepository<string, IEnumerable<Mention>> mentions)
{
this.Get["/most-mentioned/{track}", true] = async (parameters, __) =>
{
// see https://github.com/NancyFx/Nancy/issues/1154
var track = ((string)parameters.track).Replace("해시", "#");
var trackMentions = (await mentions.GetAsync(track)).ToList();
var entries = trackMentions
.GroupBy(mention => mention.UserMentionId)
.Select(g => new UserEntry
{
Id = g.Key,
IdStr = g.First().UserMentionIdStr,
Name = g.First().UserMentionName,
ScreenName = g.First().UserMentionScreenName,
Count = g.Count(),
})
.OrderByDescending(entry => entry.Count)
.Select((entry, index) =>
{
entry.Position = index + 1;
return entry;
})
.Take(10)
.ToList();
return new Leaderboard<UserEntry>
{
Entries = entries,
Count = trackMentions.Count,
Since = trackMentions.FirstOrDefault()?.MentionedAt,
};
};
}
示例3: TopTweetersRetweetersModule
public TopTweetersRetweetersModule(IRepository<string, IEnumerable<TweetRetweet>> tweets)
{
this.Get["/top-tweeters-retweeters/{track}", true] = async (parameters, __) =>
{
// see https://github.com/NancyFx/Nancy/issues/1154
var track = ((string)parameters.track).Replace("해시", "#");
var trackTweets = (await tweets.GetAsync(track)).ToList();
var entries = trackTweets
.GroupBy(tweet => tweet.UserId)
.Select(g => new UserEntry
{
Id = g.Key,
IdStr = g.First().UserIdStr,
Name = g.First().UserName,
ScreenName = g.First().UserScreenName,
Count = g.Count(),
})
.OrderByDescending(entry => entry.Count)
.Select((entry, index) =>
{
entry.Position = index + 1;
return entry;
})
.Take(10)
.ToList();
return new Leaderboard<UserEntry>
{
Entries = entries,
Count = trackTweets.Count,
Since = trackTweets.FirstOrDefault()?.TweetedRetweetedAt,
};
};
}
示例4: MainAsync
static async Task MainAsync(IRepository<SampleEntity> repo)
{
foreach (var s in await repo.GetAllAsync())
{
Console.WriteLine("{0} | {1}", s.ID, s.Name);
}
// Paged Set //
Console.WriteLine("\nPage = 2 - Page Size = 2 :");
var some = await repo.GetAsync(2, 2, s => s.ID);
foreach (var s in some)
{
Console.WriteLine("{0} | {1}", s.ID, s.Name);
}
// Updating //
var fox = await repo.FindAsync(e => e.Name == "Fox");
fox.Name = "Dog";
repo.Update(fox, fox.ID);
// Deleting //
Console.WriteLine("\n " + await repo.DeleteAsync(repo.Get(5)) + "\n");
foreach (var e in repo.GetAll())
Console.WriteLine(e.ID + " | " + e.Name);
}
示例5: MostMentionedModule
public MostMentionedModule(
IRepository<string, IEnumerable<Mention>> mentions, IIgnoredUserNamesService ignoredUserNamesService)
{
this.Get["/most-mentioned/{track}", true] = async (parameters, __) =>
{
// see https://github.com/NancyFx/Nancy/issues/1154
var track = ((string)parameters.track).Replace("해시", "#");
var trackMentions = (await mentions.GetAsync(track)).ToList();
var entries = trackMentions
.Where(item => !ignoredUserNamesService.Get().Contains(item.UserMentionScreenName))
.GroupBy(mention => mention.UserMentionId)
.Select(g => new UserEntry
{
Id = g.Key,
IdStr = g.First().UserMentionIdStr,
Name = g.First().UserMentionName,
ScreenName = g.First().UserMentionScreenName,
Count = g.Count(),
})
.OrderByDescending(entry => entry.Count)
.Select((entry, index) =>
{
entry.Position = index + 1;
return entry;
})
.Take(10)
.ToList();
return new Leaderboard<UserEntry>
{
Entries = entries,
Count = trackMentions.Count,
Since = trackMentions.Any() ? trackMentions.Min(mention => mention.MentionedAt) : (DateTime?) null,
LastActivityDateTime = trackMentions.Any()? trackMentions.Max(mention => mention.MentionedAt): (DateTime?) null,
};
};
}