本文整理汇总了C#中RepositoryFactory.Find方法的典型用法代码示例。如果您正苦于以下问题:C# RepositoryFactory.Find方法的具体用法?C# RepositoryFactory.Find怎么用?C# RepositoryFactory.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RepositoryFactory
的用法示例。
在下文中一共展示了RepositoryFactory.Find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBySeasonAndCompetition
public LeagueTable GetBySeasonAndCompetition(string seasonId, string competitionId)
{
SeasonCompetition seasonCompetition;
using (var seasonCompetitionRepository = new RepositoryFactory().CreateSeasonCompetitionRepository())
{
seasonCompetition = seasonCompetitionRepository.Find(sc => sc.SeasonId == seasonId && sc.CompetitionId == competitionId).FirstOrDefault();
if (seasonCompetition == null)
{
string message = $"Combination of season '{seasonId}' and competition '{competitionId}' does not exist";
throw new NotFoundException(message);
}
}
using (var leagueTableRepository = new RepositoryFactory().CreateLeagueTableRepository())
{
var leagueTable = leagueTableRepository.GetBySeasonCompetition(seasonCompetition.Id);
if (leagueTable == null)
{
string message = $"No league table exists for season '{seasonId}' and competition '{competitionId}'";
throw new NotFoundException(message);
}
return leagueTable;
}
}
示例2: GetByLine
public IEnumerable<Position> GetByLine(Line line)
{
using (var positionRepository = new RepositoryFactory().CreatePositionRepository())
{
var positions = positionRepository.Find(x => x.Line.Equals(line));
return positions;
}
}
示例3: PickRandom
/// <summary>
/// Picks a random <see cref="PlayerProfile"/> which has the specified Position.
/// </summary>
public PlayerProfile PickRandom(Position position)
{
using (var playerProfileRepository = new RepositoryFactory().CreatePlayerProfileRepository())
{
var playerProfiles = playerProfileRepository.Find(playerProfile => playerProfile.Positions.Contains(position)).ToList();
var pickedPlayerProfile = GetRandomPlayerProfile(playerProfiles);
return pickedPlayerProfile;
}
}
示例4: CreateGameForUser
public Game CreateGameForUser(string userId)
{
Game game;
using (var gameRepository = new RepositoryFactory().CreateGameRepository())
{
game = gameRepository.Find(x => x.UserId == null).FirstOrDefault();
}
if (game != null)
{
game.UserId = userId;
using (var repository = new RepositoryFactory().CreateUnitOfWorkRepository())
{
repository.RegisterUpdate(game);
repository.Save();
}
}
return game;
}
示例5: DeleteSeasons
public void DeleteSeasons(IUnitOfWorkRepository repository)
{
// Get all seasons for the game.
using (var seasonRepository = new RepositoryFactory().CreateSeasonRepository())
using (var seasonCompetitionRepository = new RepositoryFactory().CreateSeasonCompetitionRepository())
using (var seasonCompetitionTeamRepository = new RepositoryFactory().CreateRepository<SeasonCompetitionTeam>())
using (var roundRepository = new RepositoryFactory().CreateRoundRepository())
using (var matchRepository = new RepositoryFactory().CreateMatchRepository())
{
var seasons = seasonRepository.Find(season => season.GameId.Equals(_game.Id));
foreach (var season in seasons)
{
// Get season competitions.
var seasonCompetitions = seasonCompetitionRepository.Find(sc => sc.SeasonId.Equals(season.Id));
foreach (var seasonCompetition in seasonCompetitions)
{
// Delete relations between the season competition and the teams.
var seasonCompetitionTeams = seasonCompetitionTeamRepository.Find(team => team.SeasonCompetitionId.Equals(seasonCompetition.Id));
repository.RegisterDelete(seasonCompetitionTeams);
// Delete rounds and their matches.
var rounds = roundRepository.Find(round => round.SeasonCompetitionId.Equals(seasonCompetition.Id));
foreach (var round in rounds)
{
var matches = matchRepository.Find(match => match.RoundId.Equals(round.Id));
repository.RegisterDelete(matches);
repository.RegisterDelete(round);
}
repository.RegisterDelete(seasonCompetition);
}
repository.RegisterDelete(season);
}
}
}
示例6: GetPlayer
public Player GetPlayer(string playerId, string teamId)
{
using (var playerRepository = new RepositoryFactory().CreatePlayerRepository())
{
return playerRepository.Find(p => p.Id == playerId && p.TeamId == teamId).FirstOrDefault();
}
}