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


C# IRepository.Attach方法代码示例

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


在下文中一共展示了IRepository.Attach方法的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: Update

 public void Update(BusinessObjects.Model entity)
 {
     using (_ModelRepository = new GenericRepository<DAL.DataEntities.Model>())
     {
         entity.LastModifiedDate = DateTime.Now;
         //
         _ModelRepository.Attach((DAL.DataEntities.Model)entity.InnerEntity);
         _ModelRepository.SaveChanges();
     }
 }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:10,代码来源:ModelService.cs

示例3: Update

 public void Update(BusinessObjects.Attribute entity)
 {
     using (_AttributeRepository = new GenericRepository<DAL.DataEntities.Attribute>())
     {
         //Update the Attribute
         _AttributeRepository.Attach((DAL.DataEntities.Attribute)entity.InnerEntity);
         _AttributeRepository.SaveChanges();
     }
 }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:9,代码来源:AttributeService.cs

示例4: Update

 public void Update(BusinessObjects.CustomRule entity)
 {
     using (_CustomRuleRepository = new GenericRepository<DAL.DataEntities.CustomRule>())
     {
         //
         _CustomRuleRepository.Attach((DAL.DataEntities.CustomRule)entity.InnerEntity);
         _CustomRuleRepository.SaveChanges();
     }
 }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:9,代码来源:CustomRuleService.cs

示例5: Update

 public void Update(BusinessObjects.Relation entity)
 {
     using (_RelationRepository = new GenericRepository<DAL.DataEntities.Relation>())
     {
         //
         _RelationRepository.Attach((DAL.DataEntities.Relation)entity.InnerEntity);
         _RelationRepository.SaveChanges();
     }
 }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:9,代码来源:RelationService.cs

示例6: Update

 public void Update(BusinessObjects.Feature entity)
 {
     using (_FeatureRepository = new GenericRepository<DAL.DataEntities.Feature>())
     {
         //Update the Feature
         _FeatureRepository.Attach((DAL.DataEntities.Feature)entity.InnerEntity);
         _FeatureRepository.SaveChanges();
     }
 }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:9,代码来源:FeatureService.cs

示例7: Update

 public void Update(BusinessObjects.Configuration entity)
 {
     using (_ConfigurationRepository = new GenericRepository<DAL.DataEntities.Configuration>())
     {
         entity.LastModifiedDate = DateTime.Now;
         //
         _ConfigurationRepository.Attach((DAL.DataEntities.Configuration)entity.InnerEntity);
         _ConfigurationRepository.SaveChanges();
     }
 }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:10,代码来源:ConfigurationService.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: 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

示例11: Update

 public void Update(BusinessObjects.Constraint entity)
 {
     using (_ConstraintRepository = new GenericRepository<DAL.DataEntities.Constraint>())
     {
         //
         _ConstraintRepository.Attach((DAL.DataEntities.Constraint)entity.InnerEntity);
         _ConstraintRepository.SaveChanges();
     }
 }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:9,代码来源:ConstraintService.cs

示例12: Update

        public void Update(BLL.BusinessObjects.UITemplate entity)
        {
            using (_UITemplateRepository = new GenericRepository<DAL.DataEntities.UITemplate>())
            {
                entity.LastModifiedDate = DateTime.Now;

                //
                _UITemplateRepository.Attach((DAL.DataEntities.UITemplate)entity.InnerEntity);
                _UITemplateRepository.SaveChanges();
            }
        }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:11,代码来源:UITemplateService.cs

示例13: Update

        public void Update(BusinessObjects.FeatureSelection entity)
        {
            using (_FeatureSelectionRepository = new GenericRepository<DAL.DataEntities.FeatureSelection>())
            {
                //Update the FeatureSelection
                _FeatureSelectionRepository.Attach((DAL.DataEntities.FeatureSelection)entity.InnerEntity);
                _FeatureSelectionRepository.SaveChanges();

                //Update AttributeValues
                using (_AttributeValuesRepository = new GenericRepository<DAL.DataEntities.AttributeValue>())
                {
                    for (int i = entity.AttributeValues.Count - 1; i >= 0; i--)
                    {
                        BLL.BusinessObjects.AttributeValue BLLAttributeValue = entity.AttributeValues[i];
                        BLLAttributeValue.FeatureSelectionID = entity.ID;

                        //Add
                        if (BLLAttributeValue.ToBeDeleted == false && BLLAttributeValue.ID == 0)
                        {
                            _AttributeValuesRepository.Add((DAL.DataEntities.AttributeValue)BLLAttributeValue.InnerEntity);
                        }
                        //Update
                        else if (BLLAttributeValue.ToBeDeleted == false && BLLAttributeValue.ID != 0)
                        {
                            _AttributeValuesRepository.Attach((DAL.DataEntities.AttributeValue)BLLAttributeValue.InnerEntity);
                        }

                    }
                    _AttributeValuesRepository.SaveChanges();
                }
            }
        }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:32,代码来源:FeatureSelectionService.cs


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