static void EfAssignment2()
        {
#if EfAssignment2
            void UpdateVendor()
            {
                using (var db = new PurchaserEntities())
                {
                    var vend = new Vendor()
                    {
                        Name = "Fairy Dust"
                    };

                    db.Vendors.Add(vend);

                    db.SaveChanges();

                    vend = db.Vendors.Find(28);
                    db.Vendors.Remove(vend);

                    db.SaveChanges();
                }
            }

            UpdateVendor();
#endif
        }
        static void EfAssignment3()
        {
#if EfAssignment3
            using (var db = new PurchaserEntities())
            {
                try
                {
                    ViewsSprocsFunctions(db);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"{ex.Message}");
                }
            }
        }
        private static void ViewsSprocsFunctions(PurchaserEntities db)
        {
#if ViewSprocFunction
            string seperator = new string ('=', 40);

            // View //

            Console.WriteLine("View:");

            var summaries = db.PoSummaries.ToList();
            foreach (var sum in summaries)
            {
                Console.WriteLine($"{sum.PurchaseOrderId}\t{sum.PODate}\t{sum.Vendor}\t{sum.TotalAmount:c}");
            }

            Console.WriteLine($"{seperator}");

            // Table-Valued Functions //

            Console.WriteLine("Table-Valued Function:");

            var poDetails = db.PoDetail(1).ToList();
            foreach (var poDetail in poDetails)
            {
                Console.WriteLine($"{poDetail.PurchaseOrderId}\t{poDetail.PODate}\t{poDetail.Vendor}\t{poDetail.Part}\t{poDetail.Quantity}\t{poDetail.Value}");
            }

            Console.WriteLine($"{seperator}");

            // Stored Procedures //

            Console.WriteLine("Stored Procedure");

            var amount = new System.Data.Entity.Core.Objects.ObjectParameter("amount", typeof(decimal));
            var pop    = db.POP(1, amount);
            Console.WriteLine($"{amount.Value:c}");
#endif
#endif
        }
        static void Linq2()
        {
#if Linq2
            string seperator = new string ('=', 40);

            using (var db = new PurchaserEntities())
            {
                Console.WriteLine($"Sum of Total Purchases:");
                double totalPurchases = Convert.ToDouble(db.PurchaseOrders.Sum(pu => pu.Amount));
                Console.WriteLine($"Method: {totalPurchases:c}");
                totalPurchases = Convert.ToDouble((from pu in db.PurchaseOrders select pu.Amount).Sum());
                Console.WriteLine($"Query: {totalPurchases:c}");
                Console.WriteLine(seperator);


                Console.WriteLine($"Sorted Purchase Orders:");
                var sortedPOs = db.PurchaseOrders.OrderByDescending(pu => pu.Amount).ToList();
                Console.WriteLine($"Method: ");
                Console.WriteLine($"ID#:\tDate:\t\t\tVendorID:");
                foreach (var po in sortedPOs)
                {
                    Console.WriteLine($"{po.PurchaseOrderId}\t{po.PODate}\t{po.Amount:c}");
                }
                Console.WriteLine();

                Console.WriteLine($"Query:");
                Console.WriteLine($"ID#:\tDate:\t\t\tVendorID:");
                sortedPOs = (from pu in db.PurchaseOrders orderby pu.Amount descending select pu).ToList();
                foreach (var po in sortedPOs)
                {
                    Console.WriteLine($"{po.PurchaseOrderId}\t{po.PODate}\t{po.Amount:c}");
                }
                Console.WriteLine(seperator);


                Console.WriteLine($"Anonymous Objects:");
                Console.WriteLine($"Method:");
                var anonyPOs = db.PurchaseOrders.Select(
                    pu => new
                {
                    pu.PurchaseOrderId,
                    vendor = pu.Vendor.Name,
                    pu.Amount,
                    pu.PurchaseOrderStatusID
                }
                    ).ToList();
                Console.WriteLine($"ID#:\tVendor:\t\tAmount:\t\tStatus:");
                foreach (var pu in anonyPOs)
                {
                    Console.WriteLine($"{pu.PurchaseOrderId}\t{pu.vendor}\t{pu.Amount:c}\t{pu.PurchaseOrderStatusID}");
                }

                Console.WriteLine($"Query:");

                anonyPOs = (from pu in db.PurchaseOrders let Vendor = pu.Vendor.Name select new
                {
                    pu.PurchaseOrderId,
                    vendor = pu.Vendor.Name,
                    pu.Amount,
                    pu.PurchaseOrderStatusID
                }
                            ).ToList();
                Console.WriteLine($"ID#:\tVendor:\t\tAmount:\t\tStatus:");
                foreach (var pu in anonyPOs)
                {
                    Console.WriteLine($"{pu.PurchaseOrderId}\t{pu.vendor}\t{pu.Amount:c}\t{pu.PurchaseOrderStatusID}");
                }
            }


            //WriteLine($"\n<----- Purchase Orders by Vendor ----->");
            //var pos = PurchaseOrder.ByVendor(21);
            //foreach (var po in pos)
            //    Display(po);

            //WriteLine($"\n<----- Parts > $70 ----->");
            //var parts = Part.PartsAbove(70m);
            //foreach (var p in parts)
            //    Display(p);

            //WriteLine($"\n<----- Parts With Highest QoH ----->");
            //var part = Part.HighestQoH();
            //Display(part);

            //WriteLine($"\n<----- Receipts Descending by Cost ----->");
            //var receipts = Receipt.ByCost();
            //foreach (var receipt in receipts)
            //    Display(receipt);
#endif
        }