I'm working on a new DAL for my latest project. As the performance is essential I'm avoiding late binding/reflection as much as possible.
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:
So with other words, I want to have many different Business Objects (Class definitions with Public Properties) and each Business Object Type has it's own Handler Class that will call DAL and with provided SQL DAL will create the corresponding Business OBject and fill it using the Sub defined in the Interface. And this without using Reflection (or at leats not any expensive Reflection). Any thought or alternative solutions? The important part is that I don't want to separate Business Object Handlers(SQL etc), Business Objects (Class definitions) from DAL but still get good performance.
Thanks in advance!
Regards
Tom
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:
Code:
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
Comment