ChildDataPortal.Fetch failed on the server

ChildDataPortal.Fetch failed on the server

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


Mr X posted on Friday, January 07, 2011

Hi all,

I created an Editable Root List (EditUserList) and a Root object (EditUser which I transformed into a switchable object (dual factory and data access methods)) to be used as children in my Editable Root List. I understand you should use switchable objects only if its behaviour remains the same if used as child or root.

So I have the following objects: 

EditUserList (Editable Root List)  +  EditUser (Editable Root and Editable Child)

In my silverlight 4 application, I am using MVVM to generate my datasources in VS2010.  When the Silverlight usercontrol loads, a call is made to the GetEditUserList client side factory method of the EditUserList collection. 

EditUserList.Client.cs

public static void GetEditUserList(int Language, EventHandler<DataPortalResult<EditUserList>> callback)

        {

            var dp = new DataPortal<EditUserList>();

            dp.FetchCompleted += (o, e) =>

            {

                if (e.Error == null)

                   

 

                callback(o, e);

            };

            dp.BeginFetch(new SingleCriteria<EditUserList,int>(Language));

        }

This in turn calls the server side DataPortal_Fetch of that same object. As described here:

EditUserList.Server.cs

private void DataPortal_Fetch(SingleCriteria<EditUserList, int> Language)

{

RaiseListChangedEvents = false;

// TODO: load values

using (var ctx = ConnectionManager<SqlConnection>.GetManager("MyDatabase"))

{

using (var cm = ctx.Connection.CreateCommand())

{

                     cm.CommandText = "MyStoredProcedureName_Fetch";

                     cm.CommandType = System.Data.CommandType.StoredProcedure;

                     using (var dr = new SafeDataReader(cm.ExecuteReader()))

                     {

                            while (dr.Read())

                            {

                                Add(EditUser.GetEditUserChild(dr.GetInt32("ID"), dr.GetString("DisplayName"), dr.GetString("LoginName"), dr.GetInt32("ProfileID"), dr.GetSmartDate("LastUpdated"), dr.GetString("UpdatedBy"), Language.Value));

                            }

}

}

}

RaiseListChangedEvents = true;

}

 

At this point, the EditUserList object is accessing the database properly and is returning data through the SafeDatareader.  The data is read from the SafeDataReader and passed into the child’s GetEditUserChild factory method described here:

EditUser.Server.cs

internal static EditUser GetEditUserChild(int ID, string UserName, string LoginName, int ProfileId, SmartDate LastUpdated, string UpdatedBy, int Language)

{

return DataPortal.FetchChild<EditUser>(new ChildEditUserCriteria(ID, UserName, LoginName, ProfileId, LastUpdated, UpdatedBy, Language));

}

I created my own Criteria object to pass multiple values to the child_Fetch method:

[Serializable]

private class ChildEditUserCriteria

{

private int _id;

private string _username;

private string _loginname;

private int _profileid;

private SmartDate _lastupdated;

private string _updatedby;

private int _Language;

 

 

public int ID

{

get { return _id; }

}

 

public string UserName

{

get { return _username; }

}

 

public string LoginName

{

get { return _loginname; }

}

 

public int ProfileID

{

get { return _profileid; }

}

 

public SmartDate LastUpdated

{

get { return _lastupdated; }

}

 

public string UpdatedBy

{

get { return _updatedby; }

}

 

public int Language

{

get { return _Language; }

}

 

public ChildEditUserCriteria(int ID, string UserName, string LoginName, int ProfileId, SmartDate LastUpdated, string UpdatedBy, int Language)

{

_id = ID;

_username = UserName;

_loginname = LoginName;

_profileid = ProfileId;

_lastupdated = LastUpdated;

_updatedby = UpdatedBy;

 

_Language = Language;

}

}

 the parameters contain the values obtained from the parent list. But when the EditUser.GetEditUserChild method is calling the DataPortal.FetchChild, an error occurs. Here is the code of the Child_Fetch method:

private void Child_fetch(ChildEditUserCriteria Criteria)

{

Id = Criteria.ID;

UserName = Criteria.UserName;

ProfileID = Criteria.ProfileID;

LoginName = Criteria.LoginName;

LastUpdated = Criteria.LastUpdated;

UpdatedBy = Criteria.UpdatedBy;

}

For some reason, the application will not enter this method. 

Finally,  I get the following error when the asynch call is complete:

Csla.DataPortalException: DataPortal.Fetch failed (ChildDataPortal.Fetch failed on the server)\r\n   at Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\MethodCaller.cs:line 412\r\n   at Csla.Reflection.LateBoundObject.CallMethod(String method, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\LateBoundObject.cs:line 93\r\n   at Csla.Server.ChildDataPortal.Fetch(Type objectType, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Server\ChildDataPortal.cs:line 126\r\n   at Csla.Server.ChildDataPortal.Fetch(Type objectType, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Server\ChildDataPortal.cs:line 155\r\n   at Csla.DataPortal.FetchChild[T](Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\DataPortal.cs:line 842\r\n   at Business.EditUser.GetEditUserChild(Int32 ID, String UserName, String LoginName, Int32 ProfileId, SmartDate LastUpdated, String UpdatedBy, Int32 Language) in C:\CSLA\CSLA Projects\CSLA 4.0.1 Projects\ARDAppMaintenance\Business.Server\User\EditUser\EditUser.Server.cs:line 41\r\n   at Business.EditUserList.DataPortal_Fetch(SingleCriteria`2 Language) in C:\CSLA\CSLA Projects\CSLA 4.0.1 Projects\ARDAppMaintenance\Business.Server\User\UserList\EditUserList.Server.cs:line 46\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\MethodCaller.cs:line 545\r\n   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\MethodCaller.cs:line 549\r\n   at Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\MethodCaller.cs:line 413\r\n   at Csla.Reflection.LateBoundObject.CallMethod(String method, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\LateBoundObject.cs:line 93\r\n   at Csla.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria, DataPortalContext context) in C:\Visual Studio Projects\csla\40\Source\Csla\Server\SimpleDataPortal.cs:line 133\r\n   at Csla.DataPortal.Fetch(Type objectType, Object criteria) in C:\Visual Studio Projects\csla\40\Source\Csla\DataPortal.cs:line 245\r\n   at Csla.Server.Hosts.Silverlight.SilverlightRequestProcessor.Fetch(SilverlightCriteriaRequest request) in C:\Visual Studio Projects\csla\40\Source\Csla\Server\Hosts\Silverlight\SilverlightRequestProcessor.cs:line 146\r\nCsla.Reflection.CallMethodException: DataPortal_Fetch method call failed\r\n   at Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\MethodCaller.cs:line 412\r\n   at Csla.Reflection.LateBoundObject.CallMethod(String method, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\LateBoundObject.cs:line 93\r\n   at Csla.Server.ChildDataPortal.Fetch(Type objectType, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Server\ChildDataPortal.cs:line 126\r\n   at Csla.Server.ChildDataPortal.Fetch(Type objectType, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Server\ChildDataPortal.cs:line 155\r\n   at Csla.DataPortal.FetchChild[T](Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\DataPortal.cs:line 842\r\n   at Business.EditUser.GetEditUserChild(Int32 ID, String UserName, String LoginName, Int32 ProfileId, SmartDate LastUpdated, String UpdatedBy, Int32 Language) in C:\CSLA\CSLA Projects\CSLA 4.0.1 Projects\ARDAppMaintenance\Business.Server\User\EditUser\EditUser.Server.cs:line 41\r\n   at Business.EditUserList.DataPortal_Fetch(SingleCriteria`2 Language) in C:\CSLA\CSLA Projects\CSLA 4.0.1 Projects\ARDAppMaintenance\Business.Server\User\UserList\EditUserList.Server.cs:line 46\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\MethodCaller.cs:line 545\r\n   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\MethodCaller.cs:line 549\r\n   at Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\MethodCaller.cs:line 413\r\n   at Csla.Reflection.LateBoundObject.CallMethod(String method, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\LateBoundObject.cs:line 93\r\n   at Csla.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria, DataPortalContext context) in C:\Visual Studio Projects\csla\40\Source\Csla\Server\SimpleDataPortal.cs:line 133\r\nCsla.DataPortalException: ChildDataPortal.Fetch failed on the server\r\n   at Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\MethodCaller.cs:line 412\r\n   at Csla.Reflection.LateBoundObject.CallMethod(String method, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\LateBoundObject.cs:line 93\r\n   at Csla.Server.ChildDataPortal.Fetch(Type objectType, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Server\ChildDataPortal.cs:line 126\r\n   at Csla.Server.ChildDataPortal.Fetch(Type objectType, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Server\ChildDataPortal.cs:line 155\r\n   at Csla.DataPortal.FetchChild[T](Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\DataPortal.cs:line 842\r\n   at Business.EditUser.GetEditUserChild(Int32 ID, String UserName, String LoginName, Int32 ProfileId, SmartDate LastUpdated, String UpdatedBy, Int32 Language) in C:\CSLA\CSLA Projects\CSLA 4.0.1 Projects\ARDAppMaintenance\Business.Server\User\EditUser\EditUser.Server.cs:line 41\r\n   at Business.EditUserList.DataPortal_Fetch(SingleCriteria`2 Language) in C:\CSLA\CSLA Projects\CSLA 4.0.1 Projects\ARDAppMaintenance\Business.Server\User\UserList\EditUserList.Server.cs:line 46\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\MethodCaller.cs:line 545\r\nSystem.NotImplementedException: Child_Fetch not implemented\r\n   at Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\MethodCaller.cs:line 412\r\n   at Csla.Reflection.LateBoundObject.CallMethod(String method, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\LateBoundObject.cs:line 93\r\n   at Csla.Server.ChildDataPortal.Fetch(Type objectType, Object[] parameters) in C:\Visual Studio Projects\csla\40\Source\Csla\Server\ChildDataPortal.cs:line 126\r\n}

 

Can anyone help?  I have also tried to call dataPortal.Childfetch<EditUser>(ID, UserName…) as is shown in the MVVM “Deeper dive into Collection” SLDemo example (employeeList and employeeEdit).  At this point, I do not think MVVM is the problem because the call goes through my EditUserListViewModel and the error occurs within my Business objects, not the MVVM.

 

thanks

 

 

 

Marjon1 replied on Friday, January 07, 2011

This may be nothing more than a typo on the post, but since it is C# (not my daily language, so may be completely off), could it be due to the casing on the Child_fetch method, wouldn't it normally be Child_Fetch()?

 

JonnyBee replied on Saturday, January 08, 2011

Marjon is correct.

As the error message states: the method Child_Fetch could not be found.

Mr X replied on Monday, January 10, 2011

Thank you Marjon and JonnyBee.  It was a typo.  It works now.

 

Big Smile

Copyright (c) Marimer LLC