I'm new to Salesforce development, and trying to figure out SOQL stuff. Long time listener, first time caller.
I am running a SOQL query on ActivityHistories, and attempting to get it as a custom object. I need to do this so I can bind the data to an ASP.Net datagrid. Unfortunately, the dynamic type won't work for me, because I can't bind that to the grid.
Here is my query:
var activities = await client.QueryAsync<Activity>(@"SELECT (SELECT ActivityDate, Description
FROM ActivityHistories
ORDER BY ActivityDate DESC NULLS LAST, LastModifiedDate DESC LIMIT 500)
FROM Account
WHERE Id = '" + SalesforceId + "' LIMIT 1");
And here's the custom data type I want to use
public class Activity
{
public DateTime ActivityDate { get; set; }
public string Description { get; set; }
}
When I run this request and bind the activities.records to the datagrid, I simply get no data. The headers for the columns appear, but I don't get any of the records that are supposed to be there. Even debugging doesn't provide any additional information, it just looks like I got a blank object back. However, when I run the same query and replace Activity with dynamic, I get a whole bunch of Json that does contain everything I'm looking for.
At first, I thought maybe the deserialization into my custom object was the problem, but I did a very similar thing with Opportunity, and it works just fine, automatically converting to that custom object. This leads me to believe I'm handling something with the inner query incorrectly, and I would greatly appreciate any direction.
Here's a short summary of stuff I have read and attempted:
- http://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_activityhistory.htm
- https://salesforce.stackexchange.com/questions/48800/getting-object-type-not-accessible-error/56513#56513
- Salesforce Apex - Populating an object from SOQL query
- Tried filling out more fields in Activity to correspond with the stuff coming from the query
- Tried adjusting field types to correspond or not correspond with Activity
- Generalized Google searches of anything related to converting dynamic to strong types (that didn't end well)
- Requesting different, varying fields in the query, but finally landed on these two since these are the fields in the Salesforce documentation (link 1 above)
Thank you in advance!