Hi Shaymaa, you don't need to do that. LLBLGen simplifies that a lot. You have several options:
**The SQL you want **
SELECT
sb_ClientTelephone.ClientTelephoneId,
sb_ClientTelephone.ClientId,
sb_ZzTelephoneType.TelephoneTypeName,
sb_Telephone.TelephoneAreaCode,
sb_Telephone.TelephoneNumber
FROM(sb_ClientTelephone)
INNER JOIN sb_Telephone
ON sb_ClientTelephone.TelephoneId = sb_Telephone.TelephoneId
INNER JOIN sb_ZzTelephoneType
ON sb_Telephone.ZzTelephoneTypeId = sb_ZzTelephoneType.ZzTelephoneTypeId
WHERE(sb_ClientTelephone.ClientId = 2)
A. DynamicList (ref...)
This is a good option if you want to perform custom fetches that return read-only DataTables:
Dim fields As New ResultsetFields(5)
fields.DefineField(ClientTelephoneFields.ClientTelephoneId, 0)
fields.DefineField(ClientTelephoneFields.ClientId, 1)
fields.DefineField(TelephoneFields.TelephoneAreaCode, 2)
fields.DefineField(TelephoneFields.TelephoneNumber, 3)
fields.DefineField(ZzTelephoneTypeFields.TelephoneTypeName, 4)
Dim relations As IRelationCollection = New RelationCollection()
relations.Add(ClientTelephoneEntity.Relations.TelephoneEntityUsingTelephoneId)
relations.Add(TelephoneEntity.Relations.ZzTelephoneTypeEntityUsingTelephoneTypeId)
Dim filter As IPredicateExpression
filter.Add(ClientTelephoneFields.ClientId = 2)
Dim dynamicList As New DataTable()
Dim dao As New TypedListDAO()
dao.GetMultiAsDataTable(fields, dynamicList, 0, Nothing, filter, relations, True, Nothing, Nothing, 0, 0)
**B. TypedList (ref...)
The same as DynamicList but you can design it at LLBLGen Pro Designer.
**
C. EntityCollections (ref...)
You can fetch the ClientTelephoneCollection and still use the related collections to bind the results to a control (Grid for example). This option is two-way databinding, that means that you can fetch and save it back.
With this option you can do some stuff that would improve things:
- Using PrefetPaths (ref...)
- Fields mapped on related fields (ref...)
Any option you choose, I recommend you put your code at some Business class, a ClienTelephoneCollection partial class, or at the CODE_REGIONS. Maybe AdditionalNamespaces CODE_REGION wont be the best place. Instead you can use CustomEntityCollectionCode CODE_REGION.
Hope helpful.