コード例 #1
0
        private static void AddCustomers(NWBAContext context)
        {
            context.Customer.AddRange(
                new Customer
            {
                CustomerID   = 2100,
                CustomerName = "Matthew Bolger",
                Address      = "123 Fake Street",
                City         = "Melbourne",
                PostCode     = "3000",
                TFN          = "1337",
                State        = "VIC",
                Phone        = "(61)-94491023"
            },
                new Customer
            {
                CustomerID   = 2200,
                CustomerName = "Rodney Cocker",
                Address      = "456 Real Road",
                City         = "Melbourne",
                PostCode     = "3005",
                TFN          = "43770",
                State        = "VIC",
                Phone        = "(61)-93906170"
            },
                new Customer
            {
                CustomerID   = 2300,
                CustomerName = "Shekhar Kalra",
                Phone        = "(61)-93906170"
            });

            context.Database.OpenConnection();

            try
            {
                context.Database.ExecuteSqlRaw("SET IDENTITY_INSERT Customer ON");
                context.SaveChanges();
                context.Database.ExecuteSqlRaw("SET IDENTITY_INSERT Customer OFF");
            }
            finally
            {
                context.Database.CloseConnection();
            }
        }
コード例 #2
0
        private static void AddTransactions(NWBAContext context)
        {
            const string format         = "dd/MM/yyyy hh:mm:ss tt";
            const string openingBalance = "Opening balance";

            context.Transaction.AddRange(
                new Transaction
            {
                TransactionType = "D",
                AccountNumber   = 4100,
                Amount          = 100,
                Comment         = openingBalance,
                ModifyDate      = DateTime.ParseExact("19/12/2019 08:00:00 PM", format, null)
            },
                new Transaction
            {
                TransactionType = "D",
                AccountNumber   = 4101,
                Amount          = 500,
                Comment         = openingBalance,
                ModifyDate      = DateTime.ParseExact("19/12/2019 08:30:00 PM", format, null)
            },
                new Transaction
            {
                TransactionType = "D",
                AccountNumber   = 4200,
                Amount          = 500.95m,
                Comment         = openingBalance,
                ModifyDate      = DateTime.ParseExact("19/12/2019 09:00:00 PM", format, null)
            },
                new Transaction
            {
                TransactionType = "D",
                AccountNumber   = 4300,
                Amount          = 1250.50m,
                Comment         = "Opening balance",
                ModifyDate      = DateTime.ParseExact("19/12/2019 10:00:00 PM", format, null)
            },
                new Transaction
            {
                TransactionType = "D",
                AccountNumber   = 4100,
                Amount          = 200,
                ModifyDate      = DateTime.ParseExact("21/12/2019 08:00:00 PM", format, null)
            },
                new Transaction
            {
                TransactionType = "W",
                AccountNumber   = 4100,
                Amount          = 50,
                ModifyDate      = DateTime.ParseExact("22/12/2019 08:00:00 PM", format, null)
            },
                new Transaction
            {
                TransactionType = "W",
                AccountNumber   = 4100,
                Amount          = 50,
                ModifyDate      = DateTime.ParseExact("22/12/2019 08:00:00 PM", format, null)
            },
                new Transaction
            {
                TransactionType = "W",
                AccountNumber   = 4100,
                Amount          = 100,
                ModifyDate      = DateTime.ParseExact("24/12/2019 08:00:00 PM", format, null)
            },
                new Transaction
            {
                TransactionType = "D",
                AccountNumber   = 4100,
                Amount          = 200,
                ModifyDate      = DateTime.ParseExact("26/12/2019 08:00:00 PM", format, null)
            },
                new Transaction
            {
                TransactionType          = "T",
                AccountNumber            = 4100,
                DestinationAccountNumber = 4200,
                Amount     = 100,
                Comment    = "Owe Rodney Pizza Money",
                ModifyDate = DateTime.ParseExact("26/12/2019 08:00:00 PM", format, null)
            },

                new Transaction
            {
                TransactionType = "W",
                AccountNumber   = 4100,
                Amount          = 50,
                ModifyDate      = DateTime.ParseExact("26/12/2019 08:00:00 PM", format, null)
            },
                new Transaction
            {
                TransactionType = "W",
                AccountNumber   = 4100,
                Amount          = 25,
                ModifyDate      = DateTime.ParseExact("26/12/2019 08:00:00 PM", format, null)
            },
                new Transaction
            {
                TransactionType = "D",
                AccountNumber   = 4100,
                Amount          = 300,
                ModifyDate      = DateTime.ParseExact("01/01/2020 08:00:00 AM", format, null)
            },

                new Transaction
            {
                TransactionType = "W",
                AccountNumber   = 4100,
                Amount          = 50,
                ModifyDate      = DateTime.ParseExact("04/01/2020 08:00:00 AM", format, null)
            },
                new Transaction
            {
                TransactionType = "W",
                AccountNumber   = 4100,
                Amount          = 75,
                ModifyDate      = DateTime.ParseExact("11/01/2020 08:00:00 AM", format, null)
            },
                new Transaction
            {
                TransactionType = "W",
                AccountNumber   = 4100,
                Amount          = 25,
                ModifyDate      = DateTime.ParseExact("22/01/2020 08:00:00 AM", format, null)
            },
                new Transaction
            {
                TransactionType = "W",
                AccountNumber   = 4100,
                Amount          = 50,
                ModifyDate      = DateTime.ParseExact("28/01/2020 08:00:00 AM", format, null)
            },
                new Transaction
            {
                TransactionType = "W",
                AccountNumber   = 4100,
                Amount          = 50,
                ModifyDate      = DateTime.ParseExact("02/02/2020 08:00:00 AM", format, null)
            },
                new Transaction
            {
                TransactionType = "W",
                AccountNumber   = 4100,
                Amount          = 50,
                ModifyDate      = DateTime.ParseExact("05/02/2020 08:00:00 AM", format, null)
            });

            context.SaveChanges();
        }