Ejemplo n.º 1
0
        private static void DisplayAccountsWithTheirContactsAndCases(SoqlContext context)
        {
            var accounts = (from a in context.GetTable <Account>()
                            where !a.Name.StartsWith("Company") &&
                            a.Industry == PickAccountIndustry.Biotechnology &&
                            PickAccountIndustry.Biotechnology == a.Industry
                            select a)
                           //.Skip(1) // not implemented on all REST API versions
                           .Take(10)
                           .ToList();

            foreach (var account in accounts)
            {
                WriteLine($"Account {account.Name} Industry: {account.Industry}");
                var contacts = account.Contacts;
                foreach (var contact in contacts)
                {
                    WriteLine($"contact: {contact.Name} - {contact.Phone} - {contact.LeadSource}");

                    var cases = contact.Cases;
                    foreach (var @case in cases)
                    {
                        WriteLine($"case: {@case.Id}");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        static void DeleteAccountsStartingWithCompany(SoqlContext context)
        {
            var accounts = from a in context.GetTable <Account>()
                           where a.Name.StartsWith("Company")
                           select a;

            foreach (var account in accounts)
            {
                context.Delete(account);
            }

            context.Save();
        }
Ejemplo n.º 3
0
        static void RenameAccountsStartingWithCompany(SoqlContext context)
        {
            var accounts = from a in context.GetTable <Account>()
                           where a.Name.StartsWith("Company")
                           select a;

            foreach (var account in accounts)
            {
                var newName = $"{account.Name}_{DateTime.Now.Ticks}";
                WriteLine($"Account {account.Name} renamed to {newName}");
                account.Name = newName;
            }

            context.Save();
        }