Hi
I am new to the CSLA framework and I am trying to create and test one editable root business class based on the Project tracker example with CSLA 2.0
What are the possible reasons for the DataPortal.Create method to fail?
Public
Shared Function NewAdministrator() As AdministratorIf Not CanAddObject() Then
Throw New System.Security.SecurityException( _
"User not authorized to add a administrator")
End If
Return DataPortal.Create(Of Administrator)() This is where it fails
End Function
What are the possible reasons for the DataPortal.Create method to fail?
Thanks in advance
Hi thanks 4 the reply.
The Project tracker sample app works fine, its only the class in my app thats doesnt work on the DataPortal.Create method.
I did however donwload the 2.03 version and this obviously doesnt correct the situation
I have based my class on the Resource class in the Project tracker application.
Any pointers or ideas what might be wrong?
Ta
Hi Again
I have the following method defined in the Data Access region. is this the override you are referring to?
<RunLocal()> _
Private Overloads Sub DataPortal_Create(ByVal criteria As Criteria)
ValidationRules.CheckRules()
End Sub
Anything i need to change here?
hi, sorry for being slow here but I have te same problem and am trying to follow the thread advice without much joy!
My BO has this Factory method so as you see I am passing an Id (since I have read the data from an LLBLGen DAO layer) and then want to set the other properties from the LLBLGen object on the Business Object.
The exception thrown follows the method sig.
I'd really apprecaite any advice.
Thanks, dan
Public Shared Function NewPdaSyncHistory(ByVal id As Integer) As PdaSyncHistory
If Not CanAddObject() Then
Throw New System.Security.SecurityException("User not authorized to add a PdaSyncHistory")
End If
Return DataPortal.Create(Of PdaSyncHistory)(New Criteria(id))
End Function
<RunLocal()> _
Protected Overloads Sub DataPortal_Create(ByVal criteria As Object) MyBase.DataPortal_Create()mSyncEventId = 0
ValidationRules.CheckRules()
End Sub====================
Csla.DataPortalException was unhandled by user code
Message="DataPortal.Fetch failed (Csla.DataPortalException: DataPortal.Fetch failed (Csla.DataPortalException: DataPortal.Create failed (System.NotSupportedException: Invalid operation - create not allowed
at Csla.Core.BusinessBase.DataPortal_Create() in C:\Artemis2i\csla\Core\BusinessBase.vb:line 1185
at Artemis2i.Library.PdaSyncHistory.DataPortal_Create(Object criteria) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistory.vb:line 181) ---> Csla.Server.CallMethodException: DataPortal_Create method call failed ---> System.NotSupportedException: Invalid operation - create not allowed
at Csla.Core.BusinessBase.DataPortal_Create() in C:\Artemis2i\csla\Core\BusinessBase.vb:line 1185
at Artemis2i.Library.PdaSyncHistory.DataPortal_Create(Object criteria) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistory.vb:line 181
--- End of inner exception stack trace ---
at Csla.Core.BusinessBase.DataPortal_Create() in C:\Artemis2i\csla\Core\BusinessBase.vb:line 1185
at Artemis2i.Library.PdaSyncHistory.DataPortal_Create(Object criteria) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistory.vb:line 181
at Csla.MethodCaller.CallMethod(Object obj, MethodInfo info, Object[] parameters) in C:\Artemis2i\csla\DataPortal\MethodCaller.vb:line 123
at Csla.Server.SimpleDataPortal.Create(Type objectType, Object criteria, DataPortalContext context) in C:\Artemis2i\csla\DataPortal\Server\SimpleDataPortal.vb:line 52
--- End of inner exception stack trace ---
at Csla.Core.BusinessBase.DataPortal_Create() in C:\Artemis2i\csla\Core\BusinessBase.vb:line 1185
at Artemis2i.Library.PdaSyncHistory.DataPortal_Create(Object criteria) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistory.vb:line 181
at Csla.MethodCaller.CallMethod(Object obj, MethodInfo info, Object[] parameters) in C:\Artemis2i\csla\DataPortal\MethodCaller.vb:line 123
at Csla.Server.SimpleDataPortal.Create(Type objectType, Object criteria, DataPortalContext context) in C:\Artemis2i\csla\DataPortal\Server\SimpleDataPortal.vb:line 52
at Csla.DataPortal.Create(Type objectType, Object criteria) in C:\Artemis2i\csla\DataPortal\Client\DataPortal.vb:line 121
at Csla.DataPortal.Create[T](Object criteria) in C:\Artemis2i\csla\DataPortal\Client\DataPortal.vb:line 67
at Artemis2i.Library.PdaSyncHistory.NewPdaSyncHistory(Int32 id) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistory.vb:line 120
at Artemis2i.Library.PdaSyncHistoryList.Fetch(DateTime dateFilter) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistoryList.vb:line 91
at Artemis2i.Library.PdaSyncHistoryList.DataPortal_Fetch(Criteria criteria) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistoryList.vb:line 60) ---> Csla.Server.CallMethodException: DataPortal_Fetch method call failed ---> Csla.DataPortalException: DataPortal.Create failed (System.NotSupportedException: Invalid operation - create not allowed
at Csla.Core.BusinessBase.DataPortal_Create() in C:\Artemis2i\csla\Core\BusinessBase.vb:line 1185
at Artemis2i.Library.PdaSyncHistory.DataPortal_Create(Object criteria) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistory.vb:line 181) ---> Csla.Server.CallMethodException: DataPortal_Create method call failed ---> System.NotSupportedException: Invalid operation - create not allowed
at Csla.Core.BusinessBase.DataPortal_Create() in C:\Artemis2i\csla\Core\BusinessBase.vb:line 1185
at Artemis2i.Library.PdaSyncHistory.DataPortal_Create(Object criteria) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistory.vb:line 181
--- End of inner exception stack trace ---
at Csla.Core.BusinessBase.DataPortal_Create() in C:\Artemis2i\csla\Core\BusinessBase.vb:line 1185
at Artemis2i.Library.PdaSyncHistory.DataPortal_Create(Object criteria) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistory.vb:line 181
at Csla.MethodCaller.CallMethod(Object obj, MethodInfo info, Object[] parameters) in C:\Artemis2i\csla\DataPortal\MethodCaller.vb:line 123
at Csla.Server.SimpleDataPortal.Create(Type objectType, Object criteria, DataPortalContext context) in C:\Artemis2i\csla\DataPortal\Server\SimpleDataPortal.vb:line 52
--- End of inner exception stack trace ---
at Csla.Core.BusinessBase.DataPortal_Create() in C:\Artemis2i\csla\Core\BusinessBase.vb:line 1185
at Artemis2i.Library.PdaSyncHistory.DataPortal_Create(Object criteria) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistory.vb:line 181
at Csla.MethodCaller.CallMethod(Object obj, MethodInfo info, Object[] parameters) in C:\Artemis2i\csla\DataPortal\MethodCaller.vb:line 123
at Csla.Server.SimpleDataPortal.Create(Type objectType, Object criteria, DataPortalContext context) in C:\Artemis2i\csla\DataPortal\Server\SimpleDataPortal.vb:line 52
at Csla.DataPortal.Create(Type objectType, Object criteria) in C:\Artemis2i\csla\DataPortal\Client\DataPortal.vb:line 121
at Csla.DataPortal.Create[T](Object criteria) in C:\Artemis2i\csla\DataPortal\Client\DataPortal.vb:line 67
at Artemis2i.Library.PdaSyncHistory.NewPdaSyncHistory(Int32 id) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistory.vb:line 120
at Artemis2i.Library.PdaSyncHistoryList.Fetch(DateTime dateFilter) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistoryList.vb:line 91
at Artemis2i.Library.PdaSyncHistoryList.DataPortal_Fetch(Criteria criteria) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistoryList.vb:line 60
--- End of inner exception stack trace ---
at Csla.Core.BusinessBase.DataPortal_Create() in C:\Artemis2i\csla\Core\BusinessBase.vb:line 1185
at Artemis2i.Library.PdaSyncHistory.DataPortal_Create(Object criteria) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistory.vb:line 181
at Csla.MethodCaller.CallMethod(Object obj, MethodInfo info, Object[] parameters) in C:\Artemis2i\csla\DataPortal\MethodCaller.vb:line 123
at Csla.Server.SimpleDataPortal.Create(Type objectType, Object criteria, DataPortalContext context) in C:\Artemis2i\csla\DataPortal\Server\SimpleDataPortal.vb:line 52
at Csla.DataPortal.Create(Type objectType, Object criteria) in C:\Artemis2i\csla\DataPortal\Client\DataPortal.vb:line 121
at Csla.DataPortal.Create[T](Object criteria) in C:\Artemis2i\csla\DataPortal\Client\DataPortal.vb:line 67
at Artemis2i.Library.PdaSyncHistory.NewPdaSyncHistory(Int32 id) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistory.vb:line 120
at Artemis2i.Library.PdaSyncHistoryList.Fetch(DateTime dateFilter) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistoryList.vb:line 91
at Artemis2i.Library.PdaSyncHistoryList.DataPortal_Fetch(Criteria criteria) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistoryList.vb:line 60
at Csla.MethodCaller.CallMethod(Object obj, MethodInfo info, Object[] parameters) in C:\Artemis2i\csla\DataPortal\MethodCaller.vb:line 123
at Csla.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria, DataPortalContext context) in C:\Artemis2i\csla\DataPortal\Server\SimpleDataPortal.vb:line 116
--- End of inner exception stack trace ---
at Csla.Core.BusinessBase.DataPortal_Create() in C:\Artemis2i\csla\Core\BusinessBase.vb:line 1185
at Artemis2i.Library.PdaSyncHistory.DataPortal_Create(Object criteria) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistory.vb:line 181
at Csla.MethodCaller.CallMethod(Object obj, MethodInfo info, Object[] parameters) in C:\Artemis2i\csla\DataPortal\MethodCaller.vb:line 123
at Csla.Server.SimpleDataPortal.Create(Type objectType, Object criteria, DataPortalContext context) in C:\Artemis2i\csla\DataPortal\Server\SimpleDataPortal.vb:line 52
at Csla.DataPortal.Create(Type objectType, Object criteria) in C:\Artemis2i\csla\DataPortal\Client\DataPortal.vb:line 121
at Csla.DataPortal.Create[T](Object criteria) in C:\Artemis2i\csla\DataPortal\Client\DataPortal.vb:line 67
at Artemis2i.Library.PdaSyncHistory.NewPdaSyncHistory(Int32 id) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistory.vb:line 120
at Artemis2i.Library.PdaSyncHistoryList.Fetch(DateTime dateFilter) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistoryList.vb:line 91
at Artemis2i.Library.PdaSyncHistoryList.DataPortal_Fetch(Criteria criteria) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistoryList.vb:line 60
at Csla.MethodCaller.CallMethod(Object obj, MethodInfo info, Object[] parameters) in C:\Artemis2i\csla\DataPortal\MethodCaller.vb:line 123
at Csla.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria, DataPortalContext context) in C:\Artemis2i\csla\DataPortal\Server\SimpleDataPortal.vb:line 116
at Csla.DataPortal.Fetch(Type objectType, Object criteria) in C:\Artemis2i\csla\DataPortal\Client\DataPortal.vb:line 204
at Csla.DataPortal.Fetch[T](Object criteria) in C:\Artemis2i\csla\DataPortal\Client\DataPortal.vb:line 148
at Artemis2i.Library.PdaSyncHistoryList.GetPdaSyncHistoryList() in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistoryList.vb:line 19
at Artemis2i.Library.Nurse.DataPortal_Fetch(Criteria criteria) in C:\Artemis2i\Artemis2iLib\Nurse\Nurse.vb:line 375)"
Source="Csla"
StackTrace:
at Csla.Core.BusinessBase.DataPortal_Create() in C:\Artemis2i\csla\Core\BusinessBase.vb:line 1185
at Artemis2i.Library.PdaSyncHistory.DataPortal_Create(Object criteria) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistory.vb:line 181
at Csla.MethodCaller.CallMethod(Object obj, MethodInfo info, Object[] parameters) in C:\Artemis2i\csla\DataPortal\MethodCaller.vb:line 123
at Csla.Server.SimpleDataPortal.Create(Type objectType, Object criteria, DataPortalContext context) in C:\Artemis2i\csla\DataPortal\Server\SimpleDataPortal.vb:line 52
at Csla.DataPortal.Create(Type objectType, Object criteria) in C:\Artemis2i\csla\DataPortal\Client\DataPortal.vb:line 121
at Csla.DataPortal.Create[T](Object criteria) in C:\Artemis2i\csla\DataPortal\Client\DataPortal.vb:line 67
at Artemis2i.Library.PdaSyncHistory.NewPdaSyncHistory(Int32 id) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistory.vb:line 120
at Artemis2i.Library.PdaSyncHistoryList.Fetch(DateTime dateFilter) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistoryList.vb:line 91
at Artemis2i.Library.PdaSyncHistoryList.DataPortal_Fetch(Criteria criteria) in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistoryList.vb:line 60
at Csla.MethodCaller.CallMethod(Object obj, MethodInfo info, Object[] parameters) in C:\Artemis2i\csla\DataPortal\MethodCaller.vb:line 123
at Csla.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria, DataPortalContext context) in C:\Artemis2i\csla\DataPortal\Server\SimpleDataPortal.vb:line 116
at Csla.DataPortal.Fetch(Type objectType, Object criteria) in C:\Artemis2i\csla\DataPortal\Client\DataPortal.vb:line 204
at Csla.DataPortal.Fetch[T](Object criteria) in C:\Artemis2i\csla\DataPortal\Client\DataPortal.vb:line 148
at Artemis2i.Library.PdaSyncHistoryList.GetPdaSyncHistoryList() in C:\Artemis2i\Artemis2iLib\Pda\PdaSyncHistoryList.vb:line 19
at Artemis2i.Library.Nurse.DataPortal_Fetch(Criteria criteria) in C:\Artemis2i\Artemis2iLib\Nurse\Nurse.vb:line 375
at Csla.MethodCaller.CallMethod(Object obj, MethodInfo info, Object[] parameters) in C:\Artemis2i\csla\DataPortal\MethodCaller.vb:line 123
at Csla.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria, DataPortalContext context) in C:\Artemis2i\csla\DataPortal\Server\SimpleDataPortal.vb:line 116
at Csla.DataPortal.Fetch(Type objectType, Object criteria) in C:\Artemis2i\csla\DataPortal\Client\DataPortal.vb:line 204
at Csla.DataPortal.Fetch[T](Object criteria) in C:\Artemis2i\csla\DataPortal\Client\DataPortal.vb:line 148
at Artemis2i.Library.Nurse.GetNurse(Int32 ID) in C:\Artemis2i\Artemis2iLib\Nurse\Nurse.vb:line 265
at Artemis2i.PL.NursePL.Nurse_Select(Int32 NurseId) in C:\Artemis2i\Artemis2iPL\NursePL.vb:line 15
at WebControls_NurseDetails.PopulateNurseDetailsForm(Int32 NurseId) in C:\Artemis2i\Web\WebControls\NurseMainDetails.ascx.vb:line 82
at WebControls_NurseDetails.Page_Load(Object sender, EventArgs e) in C:\Artemis2i\Web\WebControls\NurseMainDetails.ascx.vb:line 146
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Looking at your code, you don't need the MyBase.DataPortal_Create as you are not getting any defaults here for your object from the database. Although if you did want to, you'd just write code like the stuff typically placed in the Fetch statement.
Here's a C# version.
//If you don't need to go to DataSource to get defaults, specify the RunLocal attribute
Richard.
If you look in Chapter 4 of the book, you'll see that the base class implementations of the DataPortal_XYZ methods all throw exceptions. This is on purpose, as it helps debug scenarios where you forgot to overload/override the base method.
A side-effect of this, is that you can't call the base implementation - because doing so will result in that exception being thrown.
thanks Rocky! if my co-developer hadn't borrowed my book and not returned it I would have hopefully found it out for myself!!!!
regards,
dan
To override a method you must use the exact same method
signature of the base class. This is not what you are trying to do.
Instead, you are trying to create a new method with the same
name, but a different signature. This is an overload.
VB requires that you use the Overloads keyword in that case to
explicitly state your intent to overload the base class method. This is for clarity
of code.
C# does not have a comparable overloads keyword, which I think
is less explicit (doesn’t show the developer’s intent), but does
save some typing.
In any case, if you aren’t matching the method signature
of the base class method, then you aren’t overriding, you are
overloading.
Rocky
From: elnoegarcia
[mailto:cslanet@lhotka.net]
Sent: Tuesday, September 11, 2007 12:13 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] DataPortal.Create Failed
Hi!!
The problem is that the editor shows an error if you try to override that
method, no matter if you specify the parameter or not. The message says:
"sub 'Dataportal_Create' cannot be declared 'Overrides' because it does
not override a sub in a base class"
The editor offer 2 solutions, change Overrides for Overloads or left the
signature without Overrides or Overloads (just Private Sub
Dataportal_Create()).
I recommend that Joffies only has to use Overloads and delete the argument from
the declaration of DataPortal_Create() or specify a new Criteria object when he
calls the DataPortal.Create function (method).
I don't understand why this is happenin' because I review the clases in the
CSLA framework (the generic BusinessBase class and BusinessBase class in the
Core namespace) and the methods are marked with "Protected
Overridable" and I don't know what's going on...
Noé
Copyright (c) Marimer LLC