Open mtavares628 opened 4 years ago
One of the drawbacks of using a param array as the last parameter for a method is that it becomes difficult if not impossible to pass an actual array as a parameter.
I'm certainly open to the idea that there's a solution to this, but I'm not confident that an answer exists (though a workaround does - see below).
There are unit tests for FindDataPortalMethod that test numerous combinations of parameter types, arrays, etc. If you'd like, you can try and establish a pattern that accepts your array scenario without breaking the other scenarios. If there is a solution I'm very open to implementing it.
As a workaround, you can pass your array within a "message object" - very possibly a List<DataRow>
which is easily created from an array, and easily converted back into an array.
var list = new List<DataArray>(myarray);
var array = list.ToArray();
Hi,
I too have just upgraded to the latest release and find that all my Child_Fetch methods fail. I use these to create a new instance of a phone number and address object. I'm not sure what to do, can someone provide some insight?
protected void Child_Fetch()
{
var result = DataPortal.Create<BankAddressInfoPersist>();
string[] args = { "OriginalValues" };
using (BypassPropertyChecks)
{
DataMapper.Map(result, this, args);
MarkAsChild();
MarkNew();
}
}
Then I get this:
Csla.DataPortalException
HResult=0x80131500
Message=ChildDataPortal.Fetch failed on the server
Source=Csla
StackTrace:
at Csla.Reflection.ServiceProviderMethodCaller.FindDataPortalMethod[T](Type targetType, Object[] criteria, Boolean throwOnError)
at Csla.Reflection.ServiceProviderMethodCaller.FindDataPortalMethod[T](Object target, Object[] criteria)
at Csla.Reflection.LateBoundObject.<CallMethodTryAsyncDI>d__12`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Csla.Server.DataPortalTarget.<FetchChildAsync>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Csla.Server.ChildDataPortal.<Fetch>d__9.MoveNext()
at Csla.Server.ChildDataPortal.Fetch(Type objectType)
at Csla.DataPortal.FetchChild[T]()
at AmicusBusinessConsole.Program.Main(String[] args) in C:\Users\kcabr\Source\Repos\AmicusBusiness\AmicusBusinessConsole\Program.cs:line 133
Inner Exception 1:
TargetParameterCountException: SI.Amicus.Business.ExternalAgentLibrary.BO.BankAddressInfoPersist.[FetchChild]()
Inner Exception 2:
TargetParameterCountException: SI.Amicus.Business.CommonLibrary.BO.InjectableBusinessBase`1[[SI.Amicus.Business.ExternalAgentLibrary.BO.BankAddressInfoPersist, SI.Amicus.Business.ExternalAgentLibrary, Version=1.0.7456.42805, Culture=neutral, PublicKeyToken=null]].[FetchChild]()
Inner Exception 3:
TargetParameterCountException: Csla.BusinessBase`1[[SI.Amicus.Business.ExternalAgentLibrary.BO.BankAddressInfoPersist, SI.Amicus.Business.ExternalAgentLibrary, Version=1.0.7456.42805, Culture=neutral, PublicKeyToken=null]].[FetchChild]()
Inner Exception 4:
TargetParameterCountException: Csla.Core.BusinessBase.[FetchChild]()
Inner Exception 5:
TargetParameterCountException: Csla.Core.UndoableBase.[FetchChild]()
Inner Exception 6:
TargetParameterCountException: Csla.Core.BindableBase.[FetchChild]()
Inner Exception 7:
TargetParameterCountException: Csla.Core.MobileObject.[FetchChild]()
Inner Exception 8:
TargetParameterCountException: System.Object.[FetchChild]()
Have you tried flagging your method with the [FetchChild] attribute? It should work without it, so this may be a workaround to a bug.
[FetchChild] protected void Child_Fetch()
Hi Brinawebb, gave it try, still nothing but the error.
First, I want to point out that this forum is now obsolete - please move to the new discussion forum at https://github.com/marimerllc/csla/discussions
Second, it looks like CSLA is trying to find a FetchChild
method on the type BankAddressInfoPersist
. Is that the type where you've implemented the method?
I'm in the process of trying to upgrade from 4.8.1 to 5.0.1 and I've run into an issue with the dataportal when trying to perform a child fetch passing a DataRow array as my criteria. I've basically got a read-only list that contains a child read-only list. I'm using old Ado.NET to call a stored procedure in the list dataportal and using datatables and relations to pull all the data back at once. So the dataportal tree looks something like this:
AppointmentInfocollection:
AppointmentInfo:
AppointmentEmployeeInfoCollection:
Something is going on when it gets to the child fetch of the child list. The issue appears to happen in the ServiceProviderMethodCaller.cs file in the FindDataPortalMethod method. It's looking for a criteria object array, and the code is trying to find my Child_Fetch method using the following code:
The above code is looking at the criteria array, and cycling through and trying to match up the parameter list with the parameter types of the method that it found in my code. However, instead of the criteria object being an array of DataRow array objects, it appears to be the DataRow array itself. Meanwhile the MethodParams object has the DataRow array object, so one of two things happens when I step through the code depending upon the underlying data.
If there is only one record returned then the DataRow array in the criteria object has the same length as the MethodParams object, but when cycling through the criteria object it is trying to check the DataRow in the Datarow array against the MethodParams DataRow Array itself, and it fails.
If there is more than one record returned then the length of the criteria DataRow Array ends up being greater than the length of the MethodParams object and it also fails.
To me it looks like the criteria is coming in as a DataRow array, when the code assumes that it should be an object array of DataRow arrays.
Is this a bug, or am I doing something wrong? This was never an issue before I tried upgrading, so I'm guessing it's an issue with the new methodology of not requiring hard coded dataportal names. And I know that my code is using older methodologies, but based on the change log I think it should still work in the new version. Any assistance will be greatly appreciated.