RIA services and fields mapped to related fields

Posts   
 
    
chrisf
User
Posts: 3
Joined: 08-Mar-2011
# Posted on: 08-Mar-2011 07:45:06   

Hi All,

Being new to LLBLGen I think I am missing a step in filling the data from related mapped fields into the parent class. I am using the latest build of the designer (Feb 23rd 2011) and have an entity called "Contact". There is a nullable FK (Guid) pointing to a "Person" table with related entries. I have mapped the "Firstname" and "Lastname" fields from the "Person" entity into the "Contact" entity. I return an IQueryable from a call to a RIA service, which returns the entity values from the "Contact" table just fine. The added (mapped) columns are in the "Contact" entity as I would expect, except that there are no values present. What do I need to do to get the values populated? These are only for display (read only) and are not meant to be altered on the client application at all.

below is the standard call to the RIA service (as per examples given).

public IQueryable<ContactEntity> GetContacts() { return new LinqMetaData(CreateDataAccessAdapter()).Contact; }

I am sure there is a very simple explanation, I just cannot see it right now and as I am working on an urgent project, any help would be appreciated.

Thanks, Chris.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 08-Mar-2011 09:43:28   

The mapped fields are pointing to their corresponding values in the PersonEntity. But that was not fetched as well, so you will need to fetch the Person using a PrefetchPath.

chrisf
User
Posts: 3
Joined: 08-Mar-2011
# Posted on: 08-Mar-2011 10:10:07   

Hi Walaa,

Could I impose on you for a sample code snippet of how to achieve that given the short call to the IQueryable return through the LinqMetaData? I just can't seem to lay my hands on a sample at all.

I appreciate your help

Thanks, Chris

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 08-Mar-2011 10:28:29   

Try this please:

        public IQueryable<ContactEntity> GetContacts()
        {
            return new LinqMetaData(CreateDataAccessAdapter()).Contact.WithPath(
                 new PathEdge<PersonEntity>(
                      ContactEntity.PrefetchPathPerson));
        }
chrisf
User
Posts: 3
Joined: 08-Mar-2011
# Posted on: 08-Mar-2011 10:41:26   

That's It!

Thanks Walaa - just brilliant!

I did not have a reference to

SD.LLBLGen.Pro.LinqSupportClasses set so I did not notice the ".WithPath" linq extension.

It really works like a charm now.

Great product!

Regards, Chris