当前位置: 首页>>代码示例>>C#>>正文


C# RepositoryFactory.Find方法代码示例

本文整理汇总了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;
             }
        }
开发者ID:bouwe77,项目名称:fmg,代码行数:25,代码来源:LeagueTableService.cs

示例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;
      }
 }
开发者ID:bouwe77,项目名称:fmg,代码行数:8,代码来源:PositionService.cs

示例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;
             }
        }
开发者ID:bouwe77,项目名称:fmg,代码行数:13,代码来源:PlayerProfileService.cs

示例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;
        }
开发者ID:bouwe77,项目名称:fmg,代码行数:20,代码来源:GameService.cs

示例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);
            }
             }
        }
开发者ID:bouwe77,项目名称:fmg,代码行数:39,代码来源:SeasonManager.cs

示例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();
      }
 }
开发者ID:bouwe77,项目名称:fmg,代码行数:7,代码来源:PlayerService.cs


注:本文中的RepositoryFactory.Find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。