Data Portal Error has me stumped.. Any Ideas?

Data Portal Error has me stumped.. Any Ideas?

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


RangerGuy posted on Saturday, December 09, 2006

I'm getting an error when I'm trying to create a class like so "MyObject mo = MyObject.GetNewMyObject ();" with in another method.


MyObject inherits from an abstract Base Class that inherits from BusinessBase.

The Error is as follows:
DataPortal.Create failed (System.NotSupportedException: Invalid operation - create not allowed\r\n at
Csla.Core.BusinessBase.DataPortal_Create() in C:\\csla20cs\\Csla\\Core\\BusinessBase.cs:line 983)

Michael Hildner replied on Saturday, December 09, 2006

Your bo class needs to override any DataPortal_XXX methods you want to support. I use the CodeSmith templates and the _Create looks like this:

#region Data Access - Create

[RunLocal]

protected override void DataPortal_Create(object criteria)

{

ValidationRules.CheckRules();

}

#endregion //Data Access - Create

This is described in chapter 2, under the heading "BusinessBase"

Regards,

Mike

 

RangerGuy replied on Saturday, December 09, 2006

I just figured out what was causing the error. But I don't really understand why I was declaring a variable inside the abstract base class like so MyOtherObject myOO = MyOtherObject.GetNewOtherObject(); Can you not created instances of CSLA based object within abstract classes?

guyroch replied on Saturday, December 09, 2006

You can not create an instance of an abstract class.  You must inherit from it and then instantiate this inherited class. 

RangerGuy replied on Sunday, December 10, 2006

Thanks everybody that helped :) Sorry for the delayed reply.. I'm on a killer deadline and was a little stressed LOL!

Copyright (c) Marimer LLC