static void Main(string[] args) { var settings = ConfigurationManager.ConnectionStrings["TestDB"]; var cmd = new DatabaseCommand(settings.ProviderName, settings.ConnectionString, "[dbo].[GetContacts]"); var allContacts = cmd.GetRecords(MapContact); Console.WriteLine("Listing all contacts..."); foreach (var contact in allContacts) { OutputContact(contact); } while (true) { Console.WriteLine(); Console.Write("Enter a contact ID (ctrl-c to exit): "); var id = Console.ReadLine(); // try and load the contact... cmd.Parameters = new { id }; var result = cmd.GetRecord(MapContact); if (result == null) { Console.WriteLine($"Contact with ID of {id} not found in the database!"); } else { OutputContact(cmd.GetRecord(MapContact)); } Thread.Sleep(1000); } }
static void Main(string[] args) { var settings = ConfigurationManager.ConnectionStrings["TestDB"]; var cmd = new DatabaseCommand(settings.ProviderName, settings.ConnectionString, "[dbo].[GetContacts]"); var allContacts = cmd.GetRecords(MapContact); Console.WriteLine("Listing all contacts..."); foreach (var contact in allContacts) { OutputContact(contact); } while (true) { Console.WriteLine(); Console.Write("Enter a contact ID (ctrl-c to exit): "); var id = Console.ReadLine(); // try and load the contact... cmd.Parameters = new { id }; var result = cmd.GetRecord(MapContact); if (result == null) Console.WriteLine($"Contact with ID of {id} not found in the database!"); else OutputContact(cmd.GetRecord(MapContact)); Thread.Sleep(1000); } }