Hi
I'm using Crystal Report (the version integrated in VS2005) to generate report for my app... I'm looking for some best practice to use it with LLBLGEN.
Actually i create a typed dataset with the IDE designer and design my report.
At run time i create typed dataset and fill it with entity/collection data using CreateProjection of EntityView.
Since CreateProjection requires a list of all fields to bind, i've create a function that do this automatically:
Public Shared Function ProjectEntityViewOnTable(ByVal Tb As DataTable, _
ByVal EntityVw As IEntityView) As Boolean
'Project entityview on Datatable including all the fields that have the same DB name of table's columns
If EntityVw.Count = 0 Then Return False
Dim Entity As EntityBase = EntityVw.Item(0)
Dim ProjProp As New Generic.List(Of IEntityPropertyProjector)
Dim NmCmp As String
Dim Fld As EntityField
For i As Integer = 0 To Tb.Columns.Count - 1
NmCmp = Tb.Columns(i).ColumnName
Fld = LLBLGenDAL.Utility.getEntityFieldFromDbName(Entity, NmCmp)
If Not Fld Is Nothing Then
If Not Fld.IsIdentity Then
ProjProp.Add(New EntityPropertyProjector(Fld, NmCmp))
End If
End If
Next i
EntityVw.CreateProjection(ProjProp, Tb)
End Function
The function getEntityFieldFromDbName returns the fields that have the same name in the DB
Public Shared Function getEntityFieldFromDbName(ByVal Entity As EntityBase, ByVal NomeCampo As String) As EntityField
NomeCampo = NomeCampo.ToUpper
For i As Integer = 0 To Entity.Fields.Count - 1
If Entity.Fields(i).SourceColumnName.ToUpper = NomeCampo Then
Return Entity.Fields(i)
End If
Next
Return Nothing
End Function
When i have only one row to include in the report, i'd like to create an overloaded version of ProjectEntityViewOnTable that accept a Datatable and a generic Entity, but since I have to create an EntityView to project data.. i'm not able to build the collection starting from a generic Entity.(How can I do ???)
I'm new on using LLBLGen and I'm not sure this is the right direction ... I appreciate any comment. Thanks !!!