Ticket T284048
Visible to All Users

Application.CreateCollectionSource and Application.CreateListView throws "type is non-persistent" when invoked on NonPersistentObjectSpace

created 10 years ago

Hi,

When I try to create collection source or list view for non-persistent object using following code:

C#
IObjectSpace os = new NonPersistentObjectSpace(XafTypesInfo.Instance); CollectionSourceBase cs = Application.CreateCollectionSource(os, typeof(IzvodGlavnaKnjigaSintetika), Application.FindListViewId(typeof(IzvodGlavnaKnjigaSintetika))); BindingList<IzvodGlavnaKnjigaSintetika> list = (BindingList<IzvodGlavnaKnjigaSintetika>)((ProxyCollection)cs.Collection).OriginalCollection; list.RaiseListChangedEvents = false; foreach (var item in (IEnumerable<IzvodGlavnaKnjigaSintetika>)q) list.Add(item); list.RaiseListChangedEvents = true; view = Application.CreateListView("IzvodGlavnaKnjigaSintetika_ListView", cs, false);

or

C#
IObjectSpace os = new NonPersistentObjectSpace(XafTypesInfo.Instance); View view = Application.CreateListView(os, typeof(IzvodGlavnaKnjigaSintetika), false);

I get exception:

XML
The 'Link.Module.BO.Financije.IzvodGlavnaKnjigaSintetika' type is not persistent.

I think this functions should work correctly when invoked on NonPersistentObjectSpace.

Regards,
Mario

Answers approved by DevExpress Support

created 10 years ago (modified 10 years ago)

Hello Mario,

The issue occurs because the IzvodGlavnaKnjigaSintetika ListView's DataAccessMode is set to DataView or Server. These modes are not supported for non-persistent types. Please set its DataAccessMode to Client to resolve the issue.

    Show previous comments (6)
    Anatol (DevExpress) 10 years ago

      Thank you. According to the Call Stack, I suppose that your non-persistent class has a reference to a persistent class. Since NonPersistentObjectSpace cannot work with persistent classes, the exception occurs. I have described this issue in the NonPersistentObjectSpace - Support showing persistent objects in non-persistent objects' views ticket and described a workaround for it. Please let me know if this is your case and if the workaround is helpful.

        Yes, that worked for me.
        Thanks.

        Anatol (DevExpress) 10 years ago

          You are welcome!

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.