I have a BLL class which contains properties for the fields in a Country table (CountryCode, CountryName, etc). It also has a property ioDAL, which is a reference to a DAL class (created with SubSonic 2.2), which has same named fields.
I have a LoadRecord() method which calls the DAL's FetchById() method that populates the DAL properties by calling the database (SQL Server 2005 FWIW).
What I then want to do, rather than writing code to populate each BLL property from its DAL equivalent, is to use AutoMapper (from CodePlex). I think the line should be something like
Mapper.CreateMap(ioDAL, Me)()
but this gives errors "Value of type (DAL class / namespace naming) cannot be converted to 'System.Type'" and "Value of type (BLL class / namespace naming) cannot be converted to 'System.Type'".
Can somebody please give me a guide as to what this call should be? (VB.NET VS2005)
EDIT 13-Jan-10 - Jimmy asked me to show some more code:
Imports System
Imports System.ComponentModel
Imports AutoMapper
Public Class Country_POCO_Business
' Define property as reference to the relevant DAL class
Public Property ioDAL() As DAL_VB.Test.Country
' rest of property definition here...
End Property
Public Property CountryPk() As String
' rest of property definition here...
End Property
' and so on for other field properties...
Function LoadRecord(ByVal tcPK As String) As Boolean
ioDAL = DAL_VB.Test.Country.FetchByID(tcPK)
If ioDAL.CountryPk = tcPK Then
' set the values for the B/O properties from the DAL equivalents
' THIS IS WHERE THE ERROR OCCURS...
Mapper.CreateMap(ioDAL, Me)()
Return True
Else
Return False
End If
End Function
End Class