One central part is the DAL function for populating Business Objects. One class is called in order to connect to the database with the given SQL (stored procedures can't be used in this environment) and the given Business Object or List is populated. As different Business Object types will be populated by the same function I made an Interface that all of the Business Objects implements with the Sub called "Fill". The question is - will reflection be used in this scenario? My thought was as I'm "describing" the objects trought the interface the compiler doesn't need to use Reflection. Perhaps I'm all wrong here..
Simplified code:
Expand|Select|Wrap|Line Numbers
- Object Handler:
- With New DAL.DataManager
- .Populate(Of T)(sSQL)
- End With
- Business Objects:
- Public Class Customer
- Implements DAL.EntityInterface
- Public Sub Fill(Reader as sqlClient.SQLDataReader) Implements DAL.EntityInterface.Fill
- CustomerID = Reader.Item("CustomerID"))
- CustomerName = Reader.Item("CustomerName"))
- ... and so on
- End Sub
- End Class
- Interface:
- Namespace DAL
- Public Interface EntityInterface
- Sub Fill(Reader as sqlClient.SQLDataReader)
- End Interface
- End Namespace
- DataManager:
- Public Class DataManager
- Public Function Populate(Of T As {DAL.EntityInterface, New})(ByVal sSQL As String) As T
- Reader = New DAL.GetReader(sSQL)
- If Not IsNothing(Reader) Then
- Populate.Fill(Reader)
- End IF
- End Function
- End Class
Thanks in advance!
Regards
Tom