Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Is is possible to add to add to ConstantsEnums.vb
 

Pages: 1
LLBLGen Pro Runtime Framework
Is is possible to add to add to ConstantsEnums.vb
Page:1/1 

  Print all messages in this thread  
Poster Message
like2175
User



Location:
Camberley, United Kingdom
Joined on:
27-Mar-2006 16:16:06
Posted:
83 posts
# Posted on: 29-Apr-2009 10:07:31.  
I have a PersonEntity with FirstName MiddleName and SurnameName but I often need to display the full name, so in PersonEntity I've created

Code:
Public ReadOnly Property FullName() As String
     Get
        Return Me.FirstName & Replace(" " & Me.MiddleName & " ", " ", " ") & Me.Surname
     End Get
    End Property


when filtering/sorting I reference Surname using PersonFields.Surname like:

Code:
Dim sorter As New SortExpression(PersonFields.Surname Or SortOrder.Ascending)


What I'd really like to be able to do us reference the FullName in a similar way:

Code:
Dim sorter As New SortExpression(PersonFields.FullName Or SortOrder.Ascending)


Is there anyway to get 'FullName' to be added to the ConstantsEnums.vb file during generation so that PersonFields.FullName works?     Is this a template thing?

This would be particularly helpful as I'm having trouble getting this to work:

Code:
'fields.DefineField(New EntityField("FullName", PersonFields.FirstName + " "+ PersonFields.Surname), 2, "FullName")


in
Code:
Dim fields As New ResultsetFields(3)
    fields.DefineField(TripStopPersonActivityFields.PersonId, 0)
    fields.DefineField(TripStopPersonActivityFields.PersonActivityTypeId, 1, "OnOffBoard", AggregateFunction.Sum)
    'fields.DefineField(New EntityField("FullName", PersonFields.FirstName + PersonFields.Surname), 2, "FullName")
    fields.DefineField(PersonFields.Surname, 2)
    Dim relations As IRelationCollection = New RelationCollection()
    relations.Add(TripStopPersonActivityEntity.Relations.TripStopEntityUsingTripStopId)
    relations.Add(TripStopPersonActivityEntity.Relations.PersonEntityUsingPersonId)

    Dim groupByClause As IGroupByCollection = New GroupByCollection()
    groupByClause.Add(fields(0))
    groupByClause.Add(fields(2))

    groupByClause.HavingClause = New PredicateExpression( _
     fields(1).SetExpression(TripStopPersonActivityFields.PersonActivityTypeId * 1).SetAggregateFunction(AggregateFunction.Sum) = 1)



    Dim filter As IPredicateExpression = ((TripStopFields.LocationId = locationId) And _
         (TripStopFields.StatusId <> StatusEntity.Deleted) And _
         (TripStopFields.Etd <= etd))

    Dim dynamicList As New DataTable()
    Dim dao As New TypedListDAO()
    dao.GetMultiAsDataTable(fields, dynamicList, 0, Nothing, filter, relations, True, groupByClause, Nothing, 0, 0)


whereas I can see that
Code:
fields.DefineField(PersonFields.Fullname, 2)

would work

Any help gratefully received.

vb.net 2008, winforms, self-serve, llblgenpro v2.6.
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 29-Apr-2009 10:24:28.  
PersonFields is the enum of fields mapped to database columns.

If you want to add FullName as an extra property to the entity, then you should know that filtering and sorting on this property would be done at client side not on the database side.

Otherwise you should have added a computed column in the database and refresh the catalog from the designer to include this clumn in the generated code.

Using an EntityView you can filter a collection as follows:
Code:
IPredicateExpression filter = new PredicateExpression();
filter.AddWithAnd(new EntityProperty("FullName") == "George Clooney");
customerView.Filter = filter;


  Top
like2175
User



Location:
Camberley, United Kingdom
Joined on:
27-Mar-2006 16:16:06
Posted:
83 posts
# Posted on: 29-Apr-2009 17:03:44.  
Walaa, thanks for your pointer:

I've added a FullName field to the database, which, because the db is Access 97 (with no triggers!) , I populate though an OnSave method on my PersonEntity

Code:
' __LLBLGENPRO_USER_CODE_REGION_START CustomEntityCode

    Protected Overrides Sub OnSave()
    
     Me.FullName = Me.FirstName & Replace(" " & Me.MiddleName & " ", " ", " ") & Me.Surname
     MyBase.OnSave()

    End Sub

    ' __LLBLGENPRO_USER_CODE_REGION_END
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.