ReadOnlyBase - Misunderstanding or Errata

ReadOnlyBase - Misunderstanding or Errata

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


ChristianPena posted on Wednesday, August 09, 2006

Good afternoon,

I am admittedly a CSLA beginner, but I am learning it for work now. I was attempting to create a ReadOnlyBase object as per page 399 of the VB 2005 version of the book. On that page, the factory function definition is as follows for retrieving a read only root object:

Public Shared Function GetReadOnlyRoot(ByVal id as Integer) as ReadOnlyRoot

    Return DataPortal.Create(Of ReadOnlyRoot)(New Criteria(id))

End Function

The following DataPortal_ function is defined on page 400:

Private Overloads Sub DataPortal_Fetch(ByVal criteria as Criteria)

    ' load values

End Sub

From my understanding and from the fact that my code, when modelled after this, would throw an exception, I am wondering if it should be:

Public Shared Function GetReadOnlyRoot(ByVal id as Integer) as ReadOnlyRoot

    Return DataPortal.Fetch(Of ReadOnlyRoot)(New Criteria(id))

End Function

The following exception is thrown when DataPortal.Create is used:

Unhandled Exception: Csla.DataPortalException: DataPortal.Create failed ---> Csla.Server.CallMethodException: DataPortal_Create method call failed ---> System.NotSupportedException: Invalid operation - create not allowed

It works as expected when DataPortal.Fetch is used.

Thanks in advance,

Christian

RockfordLhotka replied on Wednesday, August 09, 2006

That is certainly an error. I've noted it in the errata

http://www.lhotka.net/Vb2005Errata.aspx?id=57e2aedf-c36e-4076-8679-159a74bcc527


Thanks!

ChristianPena replied on Wednesday, August 09, 2006

Thanks Rocky.

BTW, Mike and Yogi from CES say Hi. Smile [:)]

Copyright (c) Marimer LLC