public static void Main()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["database-connection-2"].ConnectionString;

            using (var sqlConnection
                       = new SqlConnection(connectionString))
            {
                sqlConnection.Open();

                var db = NorthwindDatabase.Init(sqlConnection, commandTimeout: 3);

                var supplier = db.Suppliers.Get(9);

                // snapshotter tracks which fields change on the object

                var s = Snapshotter.Start(supplier);

                supplier.CompanyName += "_" + Guid.NewGuid().ToString().Substring(1, 4);

                db.Suppliers.Update(9, s.Diff());

                // reload it from database
                supplier = db.Suppliers.Get(9);

                ObjectDumper.Write(supplier);
            }
        }
Exemple #2
0
        public static void Main()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["database-connection-2"].ConnectionString;

            using (var sqlConnection
                       = new SqlConnection(connectionString))
            {
                sqlConnection.Open();

                var db         = NorthwindDatabase.Init(sqlConnection, commandTimeout: 2);
                int?supplierId = db.Suppliers.Insert(new
                {
                    CompanyName = Guid.NewGuid().ToString()
                });
                Console.WriteLine(string.Format("New Supplier Id is {0}", supplierId.Value));
            }
        }
        public static void Main()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["database-connection-2"].ConnectionString;

            using (var sqlConnection = new SqlConnection(connectionString))
            {
                sqlConnection.Open();

                var db = NorthwindDatabase.Init(sqlConnection, commandTimeout: 2);

                var result = db.Suppliers.All();

                foreach (var supplier in result)
                {
                    ObjectDumper.Write(supplier);
                }
            }
        }