Interface for Databining

Interface for Databining

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


shawndewet posted on Wednesday, November 08, 2006

I have a number of classes that inherit from BusinessBase that I want to use as a databinding source on a single form.  They all have a Code property and a Description property.  I want to use an interface as the bindingsource of each the two text boxes on the form, as follows: -

Public Interface ICategory

 Property Code As String

 Property Description As String

End Interface

 

Each of my businessbase classes then implement ICategory.  The binding works perfectly.

However when it comes to saving, I have to CType the bound object to the individual class type and call that type's Save method.

Ideally I would like to add a "Function Save() As BusinessBase" to the interface, and just call the interface save method from my save button.  However, because of Generics the above Function Save As BusinessBase requires a "(Of [type] )" and that is where I get stumped. Can I even do this now with generics?  What do I put as the [type] in the method definition of the interface?

Please advise.

RockfordLhotka replied on Wednesday, November 08, 2006

In version 2.1 there's an Csla.Core.ISavable interface you can use to save any editable object.

shawndewet replied on Thursday, November 09, 2006

Thanx Rocky, this gave me the pointer I needed, in that I still need to use the Interface I mentioned, but I now also added to it a "Function Save As Object" and implemented it by another "Private Function ISave As Object" that merely returns MyBase.Save.

Cheers,

Shawn.

Copyright (c) Marimer LLC