runtime business object creation


Author
Message
Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
Yes, I build all the project to test it, I tested with some BOs and same error....

I have an CRUD working, when I press the "copy" button with the last post code, the message appears:



NotImplementedException

The class [MicroFour.StrataFrame.Business.BusinessLayer] must override the property 'TableName' since it derives from MicroFour.StrataFrame.Business.BusinessLayer.



Source : MicroFour StrataFrame Business



Stack Trace:

en MicroFour.StrataFrame.Business.BusinessLayer.get_TableName()

en MicroFour.StrataFrame.Business.BusinessLayer.CreateInternalTable()

en MicroFour.StrataFrame.Business.BusinessLayer.get__CurrentDataTable(Boolean IsSharedTable)

en MicroFour.StrataFrame.Business.BusinessLayer.ChangeCurrentDataTable(DataTable NewTable, Boolean AcceptChanges, Boolean IsSharedTable)

en MicroFour.StrataFrame.Business.BusinessLayer.CopyDataFrom(BusinessLayerBase BusinessObject, BusinessCloneDataType CopyType)

en Integra4.SFStandardFormBaseABM.CopiarRegistro() en C:et\SISTEMA\integra4\Clases Base\formularios\SFStandardFormBaseABM.vb:línea 157

en Integra4.SFStandardFormBaseABM.tsbCopiar_Click(Object sender, EventArgs e) en C:et\SISTEMA\integra4\Clases Base\formularios\SFStandardFormBaseABM.vb:línea 107

en System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)

en System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)

en System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)

en System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)

en System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)

en System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)

en System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)

en System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

en System.Windows.Forms.Control.WndProc(Message& m)

en System.Windows.Forms.ScrollableControl.WndProc(Message& m)

en System.Windows.Forms.ToolStrip.WndProc(Message& m)

en System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)

en System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)

en System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)





I tested to declare _CopyBO as BusinessObject (ej: as TESTBO1) instead of "as bussinesslayer" and It worked partially...it copy the datatable..... but I have the properties of testBO1, not the actual me.PrimaryBusinessObject BusinessObject, the unique thing that I see that I can do is to declare _copyBO as [theCorrectTypeBO here], not other solution to copy the current row to call it back later like "me.primarybusinessobject.someFieldOnSqlProperty = _copyBO.someFieldOnSqlProperty"



I think that the best I can do to copy the actual record from some BO is to copy the current dataRow and restore it later... Any best idea? :/



Thanks for all
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Yes, this message is because the partial class has not been built.  When we create the partial class for the BO we automatically overwrite the TableName property, which on the BO you are referring does not have it overwritten so thus you get the error.  If you HAve built your partial class then something else is going on.  Can you post your partial class file here.  It will be the MyBo.Designer.vb file.
Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
Trent L. Taylor (09/28/2007)
Yes, this message is because the partial class has not been built. When we create the partial class for the BO we automatically overwrite the TableName property, which on the BO you are referring does not have it overwritten so thus you get the error. If you HAve built your partial class then something else is going on. Can you post your partial class file here. It will be the MyBo.Designer.vb file.




I think that the problem is that I like to create the copy of a (unknown yet on design) new business object (I trying to create a generic CRUD) and can´t use the businesslayer to define the type of _CopyBO" because it don't override the tablename property :S I not sure how to avoid this problem and copy a single record from the primarybusinessobject into a temporal 1-row business object copy, I don´t known how I can declare the _copyBO as same type that

myform.primarybusinessObject, sometype like:



dim _copybo as gettype(me.primarybusinessobject) '<---- something like this exist on VB?



Thanks and sorry for my bad english and all my newbie questions



--------------------------------------------

I repeat the code that I posted before



My "full" code:

--------------

Private _CopyBO As New MicroFour.StrataFrame.Business.BusinessLayer

Dim sFiltroAnterior As String = Me.PrimaryBusinessObject.Filter

Dim _CurrentRowIndex As Integer = Me.PrimaryBusinessObject.CurrentRowIndex



Me.PrimaryBusinessObject.Filter = Me.PrimaryBusinessObject.PrimaryKeyField & " = " & Me.PrimaryBusinessObject(Me.PrimaryBusinessObject.PrimaryKeyField)



'-- at this line the "tablename" error ocurrs

_CopyBO.CopyDataFrom(Me.PrimaryBusinessObject, MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable)



Me.PrimaryBusinessObject.Filter = sFiltroAnterior

Me.NavigateToPrimaryKey(_RegistroEnMemoriaBO(_RegistroEnMemoriaBO.PrimaryKeyField))
Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
Solution to this topic (I think :crazySmile



dim _copybo as gettype(me.primarybusinessobject) '<---- something like this exist on VB?




I found the solution w00t I have to take some class on .net Blush



My "full" working code:

--------------

Private _CopyBO As MicroFour.StrataFrame.Business.BusinessLayer

Dim sOldFilter As String = Me.PrimaryBusinessObject.Filter

Dim _CurrentRowIndex As Integer = Me.PrimaryBusinessObject.CurrentRowIndex



Me.PrimaryBusinessObject.Filter = Me.PrimaryBusinessObject.PrimaryKeyField & " = " & Me.PrimaryBusinessObject(Me.PrimaryBusinessObject.PrimaryKeyField)



'Instantiate a object from the same type as the primaryBusinessObject

_CopyBO = Activator.CreateInstance(Me.PrimaryBusinessObject.GetType)



_CopyBO.CopyDataFrom(Me.PrimaryBusinessObject, MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable)



Me.PrimaryBusinessObject.Filter = sOldFilter



'Me.NavigateToPrimaryKey(_RegistroEnMemoriaBO(_RegistroEnMemoriaBO.PrimaryKeyField))[/quote]



Now I have a _CopyBO with 1-row copy of my actual PrimaryBusinessObject Smile



Thanks and sorry for all the posts that I write for a simple topic (because my dificulties to write more understand posts)
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Fabian,



I think that the code posted won't have just one record (unless the primary BO only has one record). When you do the CopyDataFrom, you need to supply the ClearAndFillFromDefaultView option to get just the filtered records.



Of course, if what you do have works, I'm not understanding what's happening BigGrin
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yep, Greg is correct... if you filter out all but 1 row, and you want to copy just that one row, then you will need to use the ClearAndFillFromDefaultView.  The other option (ClearAndFillFromCompleteTable) will ignore the filter you set on the business object.
Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)StrataFrame User (269 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
Hello guys, that's right, some cut & paste to show the example and I make another mistake w00t I learn the clearandfillfrom... stuff thanks for all the help and support Smile



GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search