Please confirm my understanding

Please confirm my understanding

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


griff posted on Wednesday, September 26, 2012

Using Silverlight...

I have Venue BO that has an AddressID (with Address property BO).  Is this the correct way to call / create a new Venue object...see bold part

 [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
        public override void DataPortal_Create(Csla.DataPortalClient.LocalProxy<Venue>.CompletedHandler handler)
        {
            LoadProperty(VenueIDProperty, System.Threading.Interlocked.Decrement(ref _lastID));
            LoadProperty(VenueNameProperty, null);
            LoadProperty(TelephoneProperty, null);
            LoadProperty(EmailProperty, null);
            LoadProperty(ContactNameProperty, null);
            LoadProperty(NotesProperty, null);
            LoadProperty(DateNewProperty, DateTime.Now);
            LoadProperty(CreatedByProperty, Csla.ApplicationContext.User.Identity.Name);
            LoadProperty(StatusProperty, "C");
            Address.NewAddress(0,(o, e) => 
            { 
                if (e.Error != null) 
                throw e.Error; 
                else 
                SetProperty(AddressProperty, e.Object); 
                }); 
            
            base.DataPortal_Create(handler);
        }

1) Is this code okay or is there a better way.

2) Am I right to think that there is a remote chance that the ViewModel will get back the new Venue object but the new Address object has not yet been returned (due to the async call).

Copyright (c) Marimer LLC