IncludeFieldList + Grid

Posts   
 
    
jmcjq2
User
Posts: 26
Joined: 17-Nov-2009
# Posted on: 31-Aug-2010 06:36:04   

I have a method:


public EntityCollection<EventParticipantEntity> GetParticipantsByEventId(int EventId)
        {
            EntityCollection<EventParticipantEntity> output = new EntityCollection<EventParticipantEntity>();

            IncludeFieldsList fields = new IncludeFieldsList();
            fields.Add(EventParticipantFields.EventId);
            fields.Add(EventParticipantFields.ClientId);
            fields.Add(new EntityField2("ClientName", ClientFields.Surname + ", " + ClientFields.FirstName));
            fields.Add(ClientFields.Surname);
            fields.Add(ClientFields.FirstName);
            fields.Add(ClientFields.PhoneNumber);
            fields.Add(ClientFields.DateOfBirth);

            IRelationPredicateBucket bucket = new RelationPredicateBucket();

            bucket.PredicateExpression.Add(EventParticipantFields.EventId == EventId);

            IPrefetchPath2 prefetchpath = new PrefetchPath2(EntityType.EventParticipantEntity);
            prefetchpath.Add(EventParticipantEntity.PrefetchPathClient);

            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {               
                adapter.FetchEntityCollection(output, bucket, 0, null, prefetchpath, fields);               
            }

            return output;
        }

On my grid i have this:


<telerik:GridBoundColumn HtmlEncode="true" DataField="ClientName" SortExpression="Surname" UniqueName="Surname" HeaderText="Surname" />                         
                            <telerik:GridBoundColumn HtmlEncode="true" DataField="Client.FirstName" SortExpression="FirstName" UniqueName="FirstName" HeaderText="FirstName" />                         
                            <telerik:GridBoundColumn HtmlEncode="true" DataField="Client.PhoneNumber" SortExpression="PhoneNumber" UniqueName="PhoneNumber" HeaderText="Phone Number" />
                            <telerik:GridDateTimeColumn DataField="Client.DateOfBirth"  DataFormatString="{0:dd/mm/yyyy}" SortExpression="DateOfBirth" UniqueName="DateOfBirth" HeaderText="Date Of Birth" />

Why is "ClientName" always empty and the rest are fine? am I referencing incorrectly? or my method is wrong.

Thanks John

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 31-Aug-2010 07:46:27   

ClientName is not a field, I mean it's not a field in the entity. You should add a custom property in your entity that returns the full name, then use that property name in your grid.

See the second option in this post for an example: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=16711&StartAtMessage=0&#93484

David Elizondo | LLBLGen Support Team
jmcjq2
User
Posts: 26
Joined: 17-Nov-2009
# Posted on: 31-Aug-2010 08:00:13   

daelmo wrote:

ClientName is not a field, I mean it's not a field in the entity. You should add a custom property in your entity that returns the full name, then use that property name in your grid.

See the second option in this post for an example: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=16711&StartAtMessage=0&#93484

Got it!!! Thanks again smile