コード例 #1
0
ファイル: Program.cs プロジェクト: fengyu25/comp5348
        //private static readonly String sPublishQueuePath = ".\\private$\\BankTransferQueueTransacted";
        //private static void EnsureMessageQueuesExists()
        //{
        //    // Create the transacted MSMQ queue if necessary.
        //    if (!MessageQueue.Exists(sPublishQueuePath))
        //        MessageQueue.Create(sPublishQueuePath, true);
        //}

        private static void CreateDummyEntities()
        {
            using (TransactionScope lScope = new TransactionScope())
            using (BankEntityModelContainer lContainer = new BankEntityModelContainer())
            {
                if (lContainer.Accounts.Count() == 0)
                {
                    Customer lVideoStore = new Customer();
                    Account lVSAccount = new Account() { AccountNumber = 123, Balance = 0 };
                    lVideoStore.Accounts.Add(lVSAccount);

                    Customer lCustomer = new Customer();
                    Account lCustAccount = new Account() { AccountNumber = 456, Balance = 20 };
                    lCustomer.Accounts.Add(lCustAccount);


                    lContainer.Customers.AddObject(lVideoStore);
                    lContainer.Customers.AddObject(lCustomer);


                    lContainer.SaveChanges();
                    lScope.Complete();
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Create a new Customer object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 public static Customer CreateCustomer(global::System.Int32 id)
 {
     Customer customer = new Customer();
     customer.Id = id;
     return customer;
 }
コード例 #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Customers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCustomers(Customer customer)
 {
     base.AddObject("Customers", customer);
 }