我第一次看到这个。这就是我所拥有的
我从会话中获得了客户,这里我的国家代码是2个字母的代码
var selCustomer = SessionService.GetItem<Customer>(SessionKeys.SelectedCustomer);
我需要将2个字母的国家/地区代码转换为3个字母的国家/地区代码以供特定用途
var customerAddress = GeographyServiceInstance.FixAddresss(selCustomer.CustomerAddress, true);
在此阶段,当我检查信息时,selCustomer.CustomerAddress,customerAddress甚至会话中的客户都更改为3个字母代码。我不是在这里设置会话,那为什么它被覆盖了呢?
我能够在session和selCustomer.CustomerAddress没有被覆盖的地方进行的唯一方法是
var customer =
SessionService.GetItem<Customer>(SessionKeys.SelectedCustomer);
// turn customer address into 3 letter country code,
// hard way, otherwise original object and session
// address are being overwritten
Address customerAddress = null;
if (customer.CustomerAddress != null)
{
customerAddress = new Address
{
AddressId = customer.CustomerAddress.AddressId,
AddressLine1 = customer.CustomerAddress.AddressLine1,
AddressLine2 = customer.CustomerAddress.AddressLine2,
City = customer.CustomerAddress.City,
CountryCode = customer.CustomerAddress.CountryCode,
CountryInfo = customer.CustomerAddress.CountryInfo,
StateCode = customer.CustomerAddress.StateCode,
StateInfo = customer.CustomerAddress.StateInfo
};
}
customerAddress =
GeographyServiceInstance.FixAddress(customerAddress, true);