XAF – How to keep NonPersistent Objects inside Persistent BusinessObject

BusinessObject :

    public partial class LG_124_01_QPRODUCT : XPLiteObject
    {

      List<altMamüller> faltMalzemeler;
      [NonPersistent]
      public List<altMamüller> altMalzemeler
      {
          get { return faltMalzemeler; }
          set { SetPropertyValue<List<altMamüller>>(nameof(altMalzemeler), ref faltMalzemeler, value); }
      }

   public LG_124_01_QPRODUCT()
   {
    altMalzemeler = new List<altMamüller>();
   }

    }

Here is what I want to do. I use a view controller to add items to my list inside the businessobject shown above. After I add it, I want to refresh the view so that user can see changes made.

But the problem is that when view is refreshed, the object is disposed so I can’t reach it:

     task = (LG_124_01_QPRODUCT)View.CurrentObject;
    task.altMalzemeler = new List<altMamüller>();
    foreach (altMamüller note in e.PopupWindowViewSelectedObjects)
    {
        task.altMalzemeler.Add(note);
    }
    View.Refresh();

Here is the error I get:

Cannot access a disposed object.
Object name: 'AppName.Module.BusinessObjects.Database.altMamüller(855)'.

-2nd method that I have tried is using globalvariables. I have planned to assign the chosen objects from PopUpWindow to a global variable and then when the view is refreshed , I could add the chosen objects to the businessobject through the constructor. But then I learned C# has no globalvariable (I may be wrong if there is an alternative way)

-3rd method that I have tried is to add another PopupWindow after the refresh button. Here is the code

            showNotesAction.CustomizePopupWindowParams += ShowNotesAction_CustomizePopupWindowParams2;
---------------------
        private void ShowNotesAction_CustomizePopupWindowParams2(
                object sender, CustomizePopupWindowParamsEventArgs e)
        {
            IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(LG_124_01_QPRODUCT));
            Object currentObject = objectSpace.GetObject(View.CurrentObject);
            if (currentObject != null)
            {
                e.View = Application.CreateDetailView(objectSpace, currentObject);
            }
            else
            {
                objectSpace.Dispose();
            }
        }

When I try 3rd method,I get this error:

Value cannot be null. (Parameter 'args.View cannot be null. Initialize args.View with a ListView, DetailView or DashboardView created using the XafApplication.CreateXXXView methods.)

Then lastly , 4th method I have used is to put the items into Listview inside ViewController rather than Detailview but I do not know how to manipulate Listview’s CollectionSource. Here is the incomplete code:

        private void ShowNotesAction_CustomizePopupWindowParams3(object sender, CustomizePopupWindowParamsEventArgs e)
        {
            View.Refresh();
            IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(LG_124_01_QPRODUCT));
            Object currentObject = objectSpace.GetObject(View.CurrentObject);

            IMemberInfo memberinfo = Application.TypesInfo.FindTypeInfo(typeof(altMamüller)).FindMember("Tasks");
            string viewId = ModelNestedListViewNodesGeneratorHelper.GetNestedListViewId(memberinfo);
            PropertyCollectionSource collectionSource = Application.CreatePropertyCollectionSource(ObjectSpace, typeof(altMamüller), View.CurrentObject, memberinfo, viewId, CollectionSourceDataAccessMode.Server, CollectionSourceMode.Normal);


            if (currentObject != null)
            {
               e.View = Application.CreateListView(viewId, collectionSource, false);
            }
            else
            {
                objectSpace.Dispose();
            }
        }

So about the solutions, is there anyone that can help me about one of these 4 methods:

1-How to use non-persistent objects after disposal?

2-How to manipulate globalvariables such that I can assign them in businessobjects constructor

3-How to solve the null issue

4-How to manipulate collectionsource in such way that I can show these list of items

or any other solution to reassign non-persistent items to a persistent object after disposal?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật