Created
November 14, 2013 05:02
-
-
Save dlively1/7461681 to your computer and use it in GitHub Desktop.
using linq to filter a results set through the API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using SugarRest; | |
using SugarRest.Exceptions; | |
using SugarRest.Model; | |
using SugarRest.Extensions; | |
namespace SugarRestTesting | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("Starting Client ..."); | |
string url = "https://<instance>/rest/v10/"; | |
string username = "admin"; | |
string password = "password"; | |
SugarClient sugar = new SugarClient(url, username, password); | |
Console.WriteLine("connected ..."); | |
var options = new SearchOptions(); | |
options.query = "a"; | |
var results = sugar.GetBeans<Account>("Accounts", options); | |
if (results.records != null) | |
{ | |
if (results.records.Count > 0) | |
{ | |
//Linq query | |
var consultingFirms = from account in results.records | |
where account.industry == "Consulting" | |
select account; | |
if (consultingFirms != null) | |
{ | |
foreach (var a in consultingFirms) | |
{ | |
Console.WriteLine(a.name); | |
} | |
} | |
} | |
} | |
Console.WriteLine("Finished Test"); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment