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


C# IRepository.Query方法代码示例

本文整理汇总了C#中IRepository.Query方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.Query方法的具体用法?C# IRepository.Query怎么用?C# IRepository.Query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRepository的用法示例。


在下文中一共展示了IRepository.Query方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SyncBrokers

		private static void SyncBrokers(HttpClient httpClient, IRepository consoleRepository)
		{
			DatabaseInit._LogHandler.WriteLog("SyncBrokers()", LogSeverity.Information, LogCategory.DataAccess);

			var response = httpClient.GetAsync("rest/api/broker").Result;

			if (response.IsSuccessStatusCode)
			{
				var serviceBrokers = response.Content.ReadAsAsync<IEnumerable<Validus.Services.Models.Broker>>().Result;

				foreach (var serviceBroker in serviceBrokers)
				{
					if (!consoleRepository.Query<Broker>().Any(cb => cb.BrokerSequenceId == serviceBroker.Id))
					{
						consoleRepository.Add(new Broker
						{
							BrokerSequenceId = serviceBroker.Id,
							Name = serviceBroker.Name,
							Code = serviceBroker.Code,
							Psu = serviceBroker.Psu,
							GroupCode = serviceBroker.GrpCd
						});
					}
					else
					{
						var consoleBroker = consoleRepository.Query<Broker>()
						                                     .FirstOrDefault(cb => cb.BrokerSequenceId == serviceBroker.Id);

						if (consoleBroker != null)
						{
							consoleBroker.Code = serviceBroker.Code;
							consoleBroker.GroupCode = serviceBroker.GrpCd;
							consoleBroker.Name = serviceBroker.Name;
							consoleBroker.Psu = serviceBroker.Psu;

							consoleRepository.Attach(consoleBroker);
						}
					}
				}
			}
			else
			{
				DatabaseInit._LogHandler.WriteLog("Get rest/api/broker failed", LogSeverity.Warning, LogCategory.DataAccess);
			}
		}
开发者ID:Eugene-Murray,项目名称:Contract_Validus,代码行数:45,代码来源:DatabaseInit.cs

示例2: HomeModule

        public HomeModule(IRepository repository)
        {
            Get["/"] = p =>
                {
                    var feeds = repository.Query(new GetFeedsQuery()).ToArray();

                    return Negotiate
                        .WithModel(feeds)
                        .WithView("home.cshtml");
                };
        }
开发者ID:kraki5525,项目名称:FeedTheRead,代码行数:11,代码来源:HomeModule.cs

示例3: UpdateSipAddresses

        private static void UpdateSipAddresses(IRepository consoleRepository)
        {
            Dictionary<String, String> userSipAddresses = DatabaseInit.GetUserSipAddresses();
            foreach (User u in consoleRepository.Query<User>(u => u.IsActive))
	        {
                String shortName = WebSiteModuleManager.ExtractUserName(u.DomainLogon);
                if (userSipAddresses.ContainsKey(shortName))
                {
                    String sipAddress = userSipAddresses[shortName];
                    if (String.IsNullOrEmpty(u.SipAddress))
                    {
                        if (!String.IsNullOrEmpty(sipAddress))
                            u.SipAddress = sipAddress;
                    }
                    else
                    {
                        if (!u.SipAddress.Equals(sipAddress, StringComparison.InvariantCultureIgnoreCase))
                            u.SipAddress = sipAddress;
                    }
                }
	        }            
        }
开发者ID:Eugene-Murray,项目名称:EM.Contract.Validus,代码行数:22,代码来源:DatabaseInit.cs

示例4: UpdateUserPictures

 private static void UpdateUserPictures(IRepository consoleRepository)
 {
     Dictionary<String, byte[]> userPictures = DatabaseInit.GetUserPictures();
     foreach (User u in consoleRepository.Query<User>(u => u.IsActive))
     {
         String shortName = WebSiteModuleManager.ExtractUserName(u.DomainLogon);
         if (userPictures.ContainsKey(shortName))
         {
             byte[] userPic = userPictures[shortName];
             if ((userPic != null) && (userPic.Length > 0))
             {
                 if ((u.UserThumbnail == null) || (u.UserThumbnail.Length <= 0))
                 {
                     u.UserThumbnail = userPic;
                 }
                 else
                 {
                     if (!u.UserThumbnail.Equals(userPic))
                         u.UserThumbnail = userPic;
                 }
             }
         }
     }  
 }
开发者ID:Eugene-Murray,项目名称:EM.Contract.Validus,代码行数:24,代码来源:DatabaseInit.cs

示例5: CreateNewTags

        /// <summary>
        /// The create new tags.
        /// </summary>
        /// <param name="tags">
        /// The tags.
        /// </param>
        /// <param name="tagRepository">
        /// The tag repository.
        /// </param>
        /// <returns>
        /// The <see cref="IList"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// </exception>
        private IList<Tag> CreateNewTags(IList<Tag> tags, IRepository<Tag, int> tagRepository)
        {
            if (tags == null)
            {
                throw new ArgumentNullException("tags");
            }

            IList<Tag> result = new List<Tag>(tags.Count);
            for (int i = 0; i < tags.Count; ++i)
            {
                string content = tags[i].Content;
                Tag temp =
                    tagRepository.Query()
                                 .Filter(p => p.Content.Equals(content, StringComparison.Ordinal))
                                 .Get()
                                 .FirstOrDefault();
                if (temp == null)
                {
                    tagRepository.Insert(tags[i]);
                    result.Add(tags[i]);
                }
                else
                {
                    result.Add(temp);
                }
            }

            return result;
        }
开发者ID:RamanBut-Husaim,项目名称:TermWork-SignalRChat,代码行数:43,代码来源:ImageAlbumService.cs

示例6: GetCategoryData

 private void GetCategoryData(IRepository _repository)
 {
     Categories = _repository.Query<Category>(x => x == x);
 }
开发者ID:CarlosR,项目名称:Progra4_MiniAmazon,代码行数:4,代码来源:CategoryGeneralModel.cs

示例7: HomeViewModel

        public HomeViewModel(ILog log, IAccount account, ILocalize localize, IApplication application, IHistory history,
                             INavigationService navigationService, IUser user, IRepository repository,
                             IList<IExerciseType> exerciseTypes, ISettings settings)
        {
            _log = log;
            _localize = localize;
            _application = application;
            Account = account;

            _history = history;
            _history.OnHistoryItemsChanged += _history_OnHistoryItemsChanged;
            _NavigationService = navigationService;
            User = user;
            ExerciseTypes = exerciseTypes;
            _repository = repository;
            _settings = settings;
            _settings.OnSettingsChanged += _settings_OnSettingsChanged;
            _settings.Load();
            _history.Load();

            _repository.Single<User>(1).ContinueWith(t =>
                {
                    var foundUser = t.Result;
                    if (foundUser == null)
                    {
                        //this is first load of the app, set it up
                        _repository.Insert<User>(this.User).ContinueWith(task =>
                            {
                                this.User = this.User;
                                Account.AccessToken = this.User.RunkeeperToken;

                            });
                    }
                    else
                    {
                        User = foundUser;
                        Account.AccessToken = foundUser.RunkeeperToken;
                    }
                });

            if (_exerciseTypes == null || _exerciseTypes.Count == 0 ||
                (_exerciseTypes.Count == 1 && _exerciseTypes[0].Id == 0))
            {
                if (HomeViewModel.cachedTypes != null)
                {
                    this.ExerciseTypes = HomeViewModel.cachedTypes;
                    _log.Info("cache hit");
                }
                else
                {
                    _log.Info("cache miss");
                    this.ExerciseTypes = DefaultTypes;
                    _log.Info("default types set, querying");
                    _repository.Query<ExerciseType>("select * from ExerciseType").ContinueWith(t =>
                        {
                            _log.Info("query complete");
                            var types = t.Result;
                            if (types == null || types.Count == 0)
                            {

                                _log.Info("db does not have Exercise types, loading default items");
                                foreach (var e in from tt in this.ExerciseTypes orderby tt.Id select tt)
                                {
                                    _repository.Insert<ExerciseType>(e);
                                }
                            }
                            else
                            {
                                _log.Info("all excecise types retreived from the db, update local data store");
                                this.ExerciseTypes = (from tt in types select tt).ToArray();
                            }
                            _log.Info("cache extypes to static var");
                            HomeViewModel.cachedTypes = ExerciseTypes;

                        });
                }
            }
        }
开发者ID:nothingmn,项目名称:WindowsPhone.Common,代码行数:78,代码来源:HomeViewModel.cs

示例8: SyncRiskCodes

		private static void SyncRiskCodes(HttpClient httpClient, IRepository consoleRepository)
		{
			DatabaseInit._LogHandler.WriteLog("SyncRiskCodes()", LogSeverity.Information, LogCategory.DataAccess);

			var response = httpClient.GetAsync("rest/api/riskcode").Result;

			if (response.IsSuccessStatusCode)
			{
				var serviceRisks = response.Content.ReadAsAsync<IEnumerable<Validus.Services.Models.RiskCode>>().Result;

				foreach (var serviceRisk in serviceRisks)
				{
					if (!consoleRepository.Query<RiskCode>()
					                      .Any(crc => crc.Code == serviceRisk.Code))
					{
						consoleRepository.Add(new RiskCode
						{
							Code = serviceRisk.Code,
							Name = serviceRisk.Name
						});
					}
					else
					{
						var consoleRisk = consoleRepository.Query<RiskCode>()
						                                   .FirstOrDefault(crc => crc.Code == serviceRisk.Code);

						if (consoleRisk != null)
						{
							consoleRisk.Code = serviceRisk.Code;
							consoleRisk.Name = serviceRisk.Name;

							consoleRepository.Attach(consoleRisk);
						}
					}
				}
			}
			else
			{
				DatabaseInit._LogHandler.WriteLog("Get rest/api/riskcode failed", LogSeverity.Warning, LogCategory.DataAccess);
			}
		}
开发者ID:Eugene-Murray,项目名称:EM.Contract.Validus,代码行数:41,代码来源:DatabaseInit.cs

示例9: SyncUnderwriters

		private static void SyncUnderwriters(HttpClient httpClient, IRepository consoleRepository)
		{
			DatabaseInit._LogHandler.WriteLog("SyncUnderwriters()", LogSeverity.Information, LogCategory.DataAccess);

			var response = httpClient.GetAsync("rest/api/underwriter").Result;

			if (response.IsSuccessStatusCode)
			{
				var serviceUnderwriters = response.Content.ReadAsAsync<IEnumerable<Validus.Services.Models.Underwriter>>().Result;

				foreach (var serviceUnderwriter in serviceUnderwriters)
				{
					if (!consoleRepository.Query<Underwriter>().Any(cu => cu.Code == serviceUnderwriter.Code))
					{
						consoleRepository.Add(new Underwriter
						{
							Code = serviceUnderwriter.Code,
							Name = serviceUnderwriter.Name
						});
					}
					else
					{
						var consoleUnderwriter = consoleRepository.Query<Underwriter>()
						                                          .FirstOrDefault(b => b.Code == serviceUnderwriter.Code);

						if (consoleUnderwriter != null)
						{
							consoleUnderwriter.Code = serviceUnderwriter.Code;
							consoleUnderwriter.Name = serviceUnderwriter.Name;

							consoleRepository.Attach(consoleUnderwriter);
						}
					}
				}
			}
			else
			{
				DatabaseInit._LogHandler.WriteLog("Get rest/api/underwriter failed", LogSeverity.Warning, LogCategory.DataAccess);
			}
		}
开发者ID:Eugene-Murray,项目名称:EM.Contract.Validus,代码行数:40,代码来源:DatabaseInit.cs

示例10: SyncOffices

		private static void SyncOffices(HttpClient httpClient, IRepository consoleRepository)
		{
			DatabaseInit._LogHandler.WriteLog("SyncOffices()", LogSeverity.Information, LogCategory.DataAccess);

			var response = httpClient.GetAsync("rest/api/office").Result;

			if (response.IsSuccessStatusCode)
			{
				var serviceOffices = response.Content.ReadAsAsync<IEnumerable<Validus.Services.Models.Office>>().Result;

				foreach (var serviceOffice in serviceOffices.Where(so => !consoleRepository.Query<Office>()
				                                                                           .Any(co => co.Id == so.Code)))
				{
					consoleRepository.Add(new Office
					{
						Id = serviceOffice.Code,
						Name = serviceOffice.Name,
						Title = serviceOffice.Name
					});
				}
			}
			else
			{
				DatabaseInit._LogHandler.WriteLog("Get rest/api/office failed", LogSeverity.Warning, LogCategory.DataAccess);
			}
		}
开发者ID:Eugene-Murray,项目名称:EM.Contract.Validus,代码行数:26,代码来源:DatabaseInit.cs

示例11: SyncCOBs

		private static void SyncCOBs(HttpClient httpClient, IRepository consoleRepository)
		{
			DatabaseInit._LogHandler.WriteLog("SyncCOBs()", LogSeverity.Information, LogCategory.DataAccess);

			var response = httpClient.GetAsync("rest/api/cob").Result;

			if (response.IsSuccessStatusCode)
			{
				var serviceCOBs = response.Content.ReadAsAsync<IEnumerable<Validus.Services.Models.COB>>().Result;

				foreach (var serviceCOB in serviceCOBs.Where(sc => !consoleRepository.Query<COB>()
				                                                                     .Any(cc => cc.Id == sc.Code)))
				{
					consoleRepository.Add(new COB
					{
						Id = serviceCOB.Code,
						Narrative = serviceCOB.Name
					});
				}
			}
			else
			{
				DatabaseInit._LogHandler.WriteLog("Get rest/api/cob failed", LogSeverity.Warning, LogCategory.DataAccess);
			}
		}
开发者ID:Eugene-Murray,项目名称:EM.Contract.Validus,代码行数:25,代码来源:DatabaseInit.cs

示例12: SyncNonLondonBrokers

		private static void SyncNonLondonBrokers(HttpClient httpClient, IRepository consoleRepository)
		{
            DatabaseInit._LogHandler.WriteLog("SyncNonLondonBrokers()", LogSeverity.Information, LogCategory.DataAccess);

			var responseOffices = httpClient.GetAsync("rest/api/office").Result;

		    if (responseOffices.IsSuccessStatusCode)
		    {
		        var serviceOffices = responseOffices.Content.ReadAsAsync<IEnumerable<Validus.Services.Models.Office>>().Result;

		        foreach (var serviceOffice in serviceOffices)
		        {
                    DatabaseInit._LogHandler.WriteLog("SyncNonLondonBrokers()_" + serviceOffice.Code, LogSeverity.Information, LogCategory.DataAccess);

                    var responseNonLondonBroker = httpClient.GetAsync("rest/api/NonLondonBroker?office=" + serviceOffice.Code).Result;

                    if (responseNonLondonBroker.IsSuccessStatusCode)
                    {
                        var serviceNonLondonBrokers = responseNonLondonBroker.Content.ReadAsAsync<IEnumerable<Validus.Services.Models.NonLondonBroker>>().Result;

                        foreach (var serviceNonLondonBroker in serviceNonLondonBrokers)
                        {
                            if (serviceNonLondonBroker.Code == "NA") continue;
                            if (!consoleRepository.Query<NonLondonBroker>().Any(cb => cb.Code == serviceNonLondonBroker.Code))
                            {
                                consoleRepository.Add(new NonLondonBroker
                                {
                                    Name = serviceNonLondonBroker.Name,
                                    Code = serviceNonLondonBroker.Code,
                                });
                            }
                            else
                            {
                                var consoleNonLondonBroker = consoleRepository.Query<NonLondonBroker>()
                                                                     .FirstOrDefault(cb => cb.Code == serviceNonLondonBroker.Code);

                                if (consoleNonLondonBroker != null)
                                {
                                    consoleNonLondonBroker.Code = serviceNonLondonBroker.Code;
                                    consoleNonLondonBroker.Name = serviceNonLondonBroker.Name;

                                    consoleRepository.Attach(consoleNonLondonBroker);
                                }
                            }
                        }
                    }
                    else
                    {
                        DatabaseInit._LogHandler.WriteLog("Get rest/api/NonLondonBroker failed_" + serviceOffice.Code, LogSeverity.Warning, LogCategory.DataAccess);
                    } 
		        }

                if (!consoleRepository.Query<NonLondonBroker>().Any(cb => cb.Code == "NA"))
                {
                    consoleRepository.Add(new NonLondonBroker
                    {
                        Name = "Not Applicable",
                        Code = "NA",
                    });
                }


		    }
            else
            {
                DatabaseInit._LogHandler.WriteLog("Get rest/api/NonLondonBroker failed", LogSeverity.Warning, LogCategory.DataAccess);
            } 
		  
                
            
		}
开发者ID:Eugene-Murray,项目名称:EM.Contract.Validus,代码行数:71,代码来源:DatabaseInit.cs

示例13: SetupSubstitutions

        private void SetupSubstitutions()
        {
            uow = Substitute.For<IUnitOfWork>();

            tokenService = Substitute.For<IRepository<ApiToken>>();
            tokenService.Query().Returns(FakeTokens);

            uow.GetRepository<ApiToken>().Returns(tokenService);
        }
开发者ID:justinobney,项目名称:jobney.ef.learning,代码行数:9,代码来源:RequiredTokenTests.cs


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