コード例 #1
0
        public void MapsOneToManyUsingConventions()
        {
            var cust = new Customer()
            {
                Name = "Jeremy"
            };
            var order = new Order()
            {
                Customer = cust
            };

            using (ContextScope.Begin()) {
                cust.Orders.Add(order);
                cust.Save();
            }

            using (ContextScope.Begin()) {
                cust = Customer.FindAll().Single();
                cust.Orders.Count().ShouldEqual(1);
            }
        }
コード例 #2
0
        public void MapsManyToOneUsingConventions()
        {
            var cust = new Customer()
            {
                Name = "Jeremy"
            };
            var order = new Order()
            {
                Customer = cust
            };

            using (ContextScope.Begin()) {
                cust.Save();
                order.Save();
            }

            using (ContextScope.Begin()) {
                order = Order.FindById(order.Id);
                order.Customer.Name.ShouldEqual("Jeremy");
            }
        }