DataPortal in Silverlight CSLA 4.3.12

DataPortal in Silverlight CSLA 4.3.12

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


st3fanus posted on Wednesday, July 18, 2012

Hi I'm stefanus..

I want to ask from you all..

I don't know what happened here :

I use Silverlight 5, and CSLA 4.3.12 i use MVVM Light and CSLA.Xaml too..

I have  MenuList extends from ReadOnlyListBase

in the factory methods i call DataPortal.BeginFetch

But I tried to run break point in the Data Access Invocations

private void DataPortal_Fetch BUT it shown that this code is never running!!

 

Is there any something I'm missing ??

Hope anyone could help me..

 

 

Thanks a lot

stefanus

st3fanus replied on Wednesday, July 18, 2012

Hi...

 

I have tried and get that DataPortal,BeginFetch doesn't call DataPortal_Fetch in the data access method !!!

 

IS anyone could help me ?

 

thanks a lot

stefanus

JonnyBee replied on Thursday, July 19, 2012

Do you use the local proxy or Aut proxy (remote)?

Do you get an exeption returned to you  callback method?

Read this thread on using the DataPortal.BeginFetxch method: http://forums.lhotka.net/forums/t/11428.aspx 

st3fanus replied on Thursday, July 19, 2012

Hi jonny..

Thanks for your quick response ( acctually I'm waiting for someone give me something )

 

I use REMOTE dataportal NOT local mode.

# My MenuList Class

        public static void GetMenuList(EventHandler<DataPortalResult<MenuList>> callback)
        {
            DataPortal.BeginFetch<MenuList>(callback);
        }

 

        private void DataPortal_Fetch()
        {
            using (var catalog = new DirectoryCatalog(@"D:\STS\DevelopmentSource\AIS\AIS.Lib.Net\bin\Debug"))
            {
                var container = new CompositionContainer(catalog);
                container.SatisfyImportsOnce(this);
            }

            IsReadOnly = false;
            var rlce = RaiseListChangedEvents;
            RaiseListChangedEvents = false;
            using (var data = MenuDal.Fetch("teacher1"))
            {
                var item = DataPortal.FetchChild<MenuInfo>(data);
                Add(item);
            }
            RaiseListChangedEvents = rlce;
            IsReadOnly = true;

        }

#. ===============================================

 

        MenuList.GetMenuList((o, e) => {
                if (e.Error != null)
                    System.Windows.MessageBox.Show("DP ERROR : " + e.Error.Message);
                else
                {
                    Model = e.Object;
                }
            });

 

        I Got :

        DP ERROR : No Parameterless constructor defined for this object

 

I'm sorry , I'm lost for this error ?

could you give me explaination or any suggestion ?

 

thanks a lot jonny

 

Stefanus

JonnyBee replied on Thursday, July 19, 2012

All business objects in SL must have public default parameterless constructor (so we now typically never add the private constructor). 

You should probably also add a parameter to DataPortal_Fetch(object criteria).

st3fanus replied on Thursday, July 19, 2012

Hi jonny..

I've added :

 

public MenuList()
        { }

 

and changed my factory method like this :

public static void GetMenuList(string username, EventHandler<DataPortalResult<MenuList>> callback)
        {
            DataPortal.BeginFetch<MenuList>(username, callback);
        }

 

private void DataPortal_Fetch(string username)
        {
            using (var catalog = new DirectoryCatalog(@"D:\STS\DevelopmentSource\AIS\AIS.Lib.Net\bin\Debug"))
            {
                var container = new CompositionContainer(catalog);
                container.SatisfyImportsOnce(this);
            }

            IsReadOnly = false;
            var rlce = RaiseListChangedEvents;
            RaiseListChangedEvents = false;
            using (var data = MenuDal.Fetch(username))
            {
                var item = DataPortal.FetchChild<MenuInfo>(data);
                Add(item);
            }
            RaiseListChangedEvents = rlce;
            IsReadOnly = true;

        }

 

BUT I still got the same error as before ??

Is there something I'm missing ??

 

JonnyBee replied on Thursday, July 19, 2012

ALL business objects must have public default constructor.

Make sure MenuInfo and all othe BO also has public default constructor. 

st3fanus replied on Thursday, July 19, 2012

Hi jonny..

 

I have add public default constructor in my BO MenuList and MenuInfo

BUT I still got the same exception / error as before

 

I don't know why DataPortal.BeginFetch do not call DataPortal_Fetch(string username) ??

Do you still with me jonny ?

 

 

thanks a lot jonny

 

stefanus

st3fanus replied on Thursday, July 19, 2012

Hi ..

Could anyone give me a suggestions ??

 

thanks a lot

Copyright (c) Marimer LLC