Hello,
I've got the following method:
/// <summary>
/// Insert or Update an address.
/// </summary>
/// <param name="u4Address"></param>
/// <returns></returns>
private AddressEntity InsertOrUpdateAddress(getdebtors_ttAddressRow u4Address)
{
try
{
AddressEntity addressEntity = new AddressEntity(u4Address.AddressCode)
{
AddressCode = u4Address.AddressCode,
AddressDescr = u4Address.AddressDescr,
AddressType = u4Address.AddressType,
CountryName = u4Address.CountryName,
DebtorCode = u4Address.DebtorCode,
EanCode = u4Address.EanCode,
Place = u4Address.Place,
Priority = u4Address.Priority,
SearchKey = u4Address.SearchKey,
Street = u4Address.Street,
Zipcode = u4Address.Zipcode
};
//Insert of Update the address. If no data is changed (IsDirty = false) no update query is executed.
addressEntity.Save();
return addressEntity;
}
catch (Exception ex)
{
DigibizException.LogException(ex);
return null;
}
}
This method is being executed in a foreach loop:
foreach (getdebtors_ttDebtorRow u4Debtor in totalDebtors)
{
//Insert or Update the debtor.
InsertOrUpdateDebtor(u4Debtor);
}
totalDebtors contains 10263 rows. The code runs perfect for the first 4943 rows, but after this I get the following exception:
Exception: Object reference not set to an instance of an object. - StackTrace: at Eurofysica.BusinessLogic.BLL.Controllers.MemberController.InsertOrUpdateAddress(getdebtors_ttAddressRow u4Address) in C:\SVN\Eurofysica\Eurofysica.UmbracoExtension\Eurofysica.BusinessLogic\BLL\Controllers\MemberController.cs:line 185
Does anybody know how this is possible?