Add property to ReadOnlyListBase, not work?

Add property to ReadOnlyListBase, not work?

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


ddredstar posted on Tuesday, December 14, 2010

I add a property TotalCount to ReadOnlyListBase for return Total Records Count(for paging)

        private int? totalCount=0;
        public int? TotalCount
        {
            get { return totalCount; }
            private set
            {
                this.totalCount = value;
            }
        }

and set TotalCount in DataPortal_Fetch method, but i always get TotalCount equals 0 in my silverlight control

 

Please help me out!

JonnyBee replied on Tuesday, December 14, 2010

Hi,

Csla does not support managed properties on a list and the recommended solution is to have a property on a parent object  that own the list.

Read more about it in this thread: http://forums.lhotka.net/forums/p/9828/46128.aspx

sergeyb replied on Tuesday, December 14, 2010

If you have to do it, you can try to add the following code to your class.  I have not tested that, but it should work.

  protected override void OnGetState(SerializationInfo info, StateMode mode)
        {
            info.AddValue("totalCount", totalCount);

            base.OnGetState(info, mode);
        }

        protected override void OnSetState(SerializationInfo info, StateMode mode)
        {
            totalCount = (int?)info.Values["totalCount"].Value;
            base.OnSetState(info, mode);
        }

Copyright (c) Marimer LLC