Quantcast
Channel: CSLA .NET
Viewing all articles
Browse latest Browse all 764

BeginSave bug in 4.5+

$
0
0

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?

Viewing all articles
Browse latest Browse all 764

Trending Articles