using System.Data.SqlClient;
using System.Collections.Generic;
using Microsoft.Data.SqlClient;
public static void Main()
var cn = String.Concat(FiddleHelper.GetConnectionStringSqlServerW3Schools(), ";TrustServerCertificate=true");
using (var connection = new Microsoft.Data.SqlClient.SqlConnection(cn))
var orderDetails = connection.Query<OrderDetail>("SELECT TOP 5 * FROM OrderDetails;").ToList();
FiddleHelper.WriteTable(orderDetails);
catch (Microsoft.Data.SqlClient.SqlException error)
Console.WriteLine("SqlException: {0}", error);
catch (ArgumentNullException error)
Console.WriteLine("ArgumentNullException: {0}", error);
Console.WriteLine("Exception: {0}", error.Message);
Console.WriteLine("Main code has completed");
public int OrderDetailID { get; set; }
public int OrderID { get; set; }
public int ProductID { get; set; }
public int Quantity { get; set; }