BeginSave bug in 4.5+

BeginSave bug in 4.5+

Old forum URL: forums.lhotka.net/forums/t/11975.aspx


Killian35 posted on Friday, May 10, 2013

Hello,

I have a Silverlight CSLA project in VS2010 and it had been working with 4.3+ just fine. Then I upgraded to 4.5.10 when that was released using Nuget. Unknown at the time, the BeginSave method would fail to call the Saved event if an exception was thrown in the DataPortal_Update method. I didn't test any other scenarios. It used to be called in the 4.3.x version. The Csla.Xaml.ViewModel.BeginSave depends on the Saved event, so I suspect the new behavior is not expected.

Using the following code, the same differing results were generated when referencing the specified versions.

        private static void Main()
        {
            var obj = MyBusiness.Get(2);
            obj.Id = 3;
            obj.Saved += (o, e) => Debug.WriteLine("Saved");
            obj.BeginSave();
 
            Console.ReadKey();
        }
 
        [Serializable]
        public class MyBusiness : BusinessBase<MyBusiness>
        {
            public static readonly PropertyInfo<int> IdProperty = RegisterProperty<int>(c => c.Id);
            public int Id
            {
                get { return GetProperty(IdProperty); }
                set { SetProperty(IdProperty, value); }
            }
 
            public static MyBusiness Get(int id)
            {
                return DataPortal.Fetch<MyBusiness>(id);
            }
 
            private void DataPortal_Fetch(int id)
            {
                using (BypassPropertyChecks)
                {
                    Id = id;
                }
            }
 
            protected override void DataPortal_Update()
            {
                throw new Exception("Failure");
            }
        }
Is there a bug in 4.5+ or is the behavior because I'm using version 4.5.10 in VS2010?

RockfordLhotka replied on Friday, May 10, 2013

This is a known issue that has been fixed in more recent versions of 4.5.

Killian35 replied on Friday, May 10, 2013

Thanks for responding!

Copyright (c) Marimer LLC