Example #1
0
        public void CreatePointTest()
        {
            var allAddresses = _target.Addresses
                               .Where(x => x.Point == null)
                               .ToList();

            void UpdateAddressWithPoint(Domain.Model.Address obj)
            {
                if (!obj.Latitude.HasValue || !obj.Longitude.HasValue)
                {
                    return;
                }

                obj.Point = new Point(obj.Latitude.Value, obj.Longitude.Value);
                _target.Attach(obj);
                _target.Entry(obj).State = EntityState.Modified;
            }

            allAddresses.ForEach(UpdateAddressWithPoint);
            _target.SaveChanges();
        }