'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 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 slyp93