Access Lookup Field With SalesforceSharp

283 views Asked by At

How can I query a lookup field in SalesforceSharp? When I run this query:

SELECT id,
AccountId,
Contact.Account.peaksyn_mm__Member_Family__c
From Contact limit 2

in Force.com's Developer Console, peaksyn_mm__Member_Family__c is "Y" or "N". But when I run the query with SalesforceSharp

var contact_records = client.Query<SFContact>(@"SELECT id,
AccountId,
Contact.Account.peaksyn_mm__Member_Family__c
From Contact limit 2");

foreach (var r in contact_records)
{
    Console.Log( r.id + ": " + (r.peaksyn_mm__Member_Family__c == null).ToString() );
}

with this class

public class SFContact
{
    public string id { get; set; }
    public string AccountId { get; set; }
    public string peaksyn_mm__Member_Family__c { get; set; }
}

r.peaksyn_mm__Member_Family__c is null for every record. Is there a syntax I need to access the field in the Account object?

1

There are 1 answers

1
user3440239 On BEST ANSWER

You have to use r.account.peaksyn_mm__Member_Family__c instead of r.peaksyn_mm__Member_Family__c