Search code examples
c#salesforcesoql

How can i get Salesforce soql query results to a datatable?


I have a soql query:

SELECT Amount, Id, Name, (SELECT Quantity, ListPrice,
 PriceBookEntry.UnitPrice, PricebookEntry.Name,
  PricebookEntry.product2.Family FROM OpportunityLineItems)
 FROM Opportunity

This gives results in the developer console, but how can i get this into a datatable with the column names prefixed with the entity using c# ,so Opportunity_Amount, Opportunity_Id etc ?

Is there a standard wrapper that i can use that will work for any query ?


Solution

  • You can use the nuget package DeveloperForce.Force to interact with Salesforce's REST APIs and query salesforce. I'm working on the same challenge to convert the query results returned from the API into a datatable.