private byte[] CreateDbaseRecord(Parcel parcel, AddressLinkSyndicationItem address, SyndicationContext context)
        {
            var record = new AddressLinkDbaseRecord
            {
                objecttype = { Value = "Perceel" },
                adresobjid = { Value = string.IsNullOrEmpty(parcel.Identificator.ObjectId) ? "" : parcel.Identificator.ObjectId },
            };

            if (address != null)
            {
                if (!string.IsNullOrEmpty(address.PersistentLocalId))
                {
                    record.adresid.Value = Convert.ToInt32(address.PersistentLocalId);
                }

                record.voladres.Value = AddressBuildingUnitLinkProjections.CreateCompleteAddress(address, context);
            }

            return(record.ToBytes(_encoding));
        }
        private async Task AddSyndicationItemEntry(AtomEntry <SyndicationItem <Address> > entry, SyndicationContext context, CancellationToken ct)
        {
            var latestItem = await context
                             .AddressLinkAddresses
                             .FindAsync(entry.Content.Object.AddressId);

            if (latestItem == null)
            {
                latestItem = new AddressLinkSyndicationItem
                {
                    AddressId         = entry.Content.Object.AddressId,
                    Version           = entry.Content.Object.Identificator?.Versie,
                    Position          = long.Parse(entry.FeedEntry.Id),
                    PersistentLocalId = entry.Content.Object.Identificator?.ObjectId,
                    IsComplete        = entry.Content.Object.IsComplete,
                    BoxNumber         = entry.Content.Object.BoxNumber,
                    HouseNumber       = entry.Content.Object.HouseNumber,
                    PostalCode        = entry.Content.Object.PostalCode,
                    StreetNameId      = entry.Content.Object.SteetnameId
                };

                await context
                .AddressLinkAddresses
                .AddAsync(latestItem, ct);
            }
            else
            {
                latestItem.Version           = entry.Content.Object.Identificator?.Versie;
                latestItem.Position          = long.Parse(entry.FeedEntry.Id);
                latestItem.PersistentLocalId = entry.Content.Object.Identificator?.ObjectId;
                latestItem.IsComplete        = entry.Content.Object.IsComplete;
                latestItem.BoxNumber         = entry.Content.Object.BoxNumber;
                latestItem.HouseNumber       = entry.Content.Object.HouseNumber;
                latestItem.PostalCode        = entry.Content.Object.PostalCode;
                latestItem.StreetNameId      = entry.Content.Object.SteetnameId;
            }

            var addressBuildingUnitLinkExtractItems =
                context.AddressBuildingUnitLinkExtract
                .Where(x => x.AddressId == latestItem.AddressId)
                .AsEnumerable()
                .Concat(context.AddressBuildingUnitLinkExtract.Local.Where(x => x.AddressId == latestItem.AddressId));

            foreach (var addressBuildingUnitLinkExtractItem in addressBuildingUnitLinkExtractItems)
            {
                addressBuildingUnitLinkExtractItem.AddressPersistentLocalId = latestItem.PersistentLocalId;
                var completeAddress = AddressBuildingUnitLinkProjections.CreateCompleteAddress(latestItem, context);

                UpdateBuildingUnitDbaseRecordField(addressBuildingUnitLinkExtractItem, record =>
                {
                    record.adresid.Value  = Convert.ToInt32(latestItem.PersistentLocalId);
                    record.voladres.Value = completeAddress;
                });
            }

            var addreesAddressParcelLinkExtractItems =
                context.AddressParcelLinkExtract
                .Where(x => x.AddressId == latestItem.AddressId)
                .AsEnumerable()
                .Concat(context.AddressParcelLinkExtract.Local.Where(x => x.AddressId == latestItem.AddressId));

            foreach (var addressParcelLinkExtractItem in addreesAddressParcelLinkExtractItems)
            {
                addressParcelLinkExtractItem.AddressPersistentLocalId = latestItem.PersistentLocalId;
                var completeAddress = AddressBuildingUnitLinkProjections.CreateCompleteAddress(latestItem, context);

                UpdateParcelDbaseRecordField(addressParcelLinkExtractItem, record =>
                {
                    record.adresid.Value  = Convert.ToInt32(latestItem.PersistentLocalId);
                    record.voladres.Value = completeAddress;
                });
            }
        }