Skip to content
Dan Lively edited this page Oct 29, 2013 · 1 revision

Example search

Get list of accounts:

var accounts = sugar.GetBeans<Account>("Accounts");

if (accounts.records.Count > 0)
{
    Console.WriteLine("Number of records is = " + accounts.records.Count.ToString());
    foreach (Account record in accounts.records)
    {
        Console.WriteLine(record.name);
    }
}

Search for Accounts named "Acme" using SearchOptions

//limit number of fields to return
List<string> fields = new List<string>() { "name", "description", "phone_office" };

SearchOptions options = new SearchOptions();
options.query = "Acme";
options.fields = string.Join(",", fields.ToArray());//creates comma seperated list

var accounts = sugar.GetBeans<Account>("Accounts", options);

if (accounts.records.Count > 0)
{
    Console.WriteLine("Number of records is = " + accounts.records.Count.ToString());
    foreach (Account record in accounts.records)
    {
        Console.WriteLine(record.name);
    }
}

Clone this wiki locally