示例#1
0
 public static Guid Insert(Customer customer)
 {
     foreach (var salesRepresentative in customer.CustomerRepresentatives)
     {
         if (salesRepresentative.IsNew)
         {
             Insert(salesRepresentative);
         }
     }
     return(Nh.InsertIntoDb(customer));
 }
示例#2
0
        /// <summary>
        /// Use this to verify that the mapping file has mapped an association as mandatory (ie not-null='true')
        /// </summary>
        /// <remarks>
        /// <example>
        /// This verifies that the association from claim to claimant is mandatory ie claim must have
        /// a reference to claimant before it can be persisted:
        /// <c>VerifyInsertThrowsBecausePropertyReferencesUnsavedInstance(claim, x => x.Claimant);</c>
        /// </example>
        /// </remarks>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="PropertyT">the type of the property that is being tested</typeparam>
        /// <param name="objectUnderTest"></param>
        /// <param name="propertyReferencingUnsavedInstance">expression that references the property that is being tested as a mandatory association</param>
        public static void VerifyInsertThrowsBecausePropertyReferencesUnsavedInstance <T, PropertyT>
            (T objectUnderTest, Expression <Func <T, PropertyT> > propertyReferencingUnsavedInstance)
        {
            string expectedMsg = String.Format("not-null property references a null or transient value");
            var    ex          = Assert.Throws <PropertyValueException>(() => Nh.InsertIntoDb(objectUnderTest));

            Assert.That(ex.Message, Is.StringContaining(expectedMsg));

            string propertyName = ReflectionUtil.GetProperty(propertyReferencingUnsavedInstance).Name;

            Assert.That(ex.Message, Is.StringContaining(propertyName));
        }
        public void NHibernateCriteriaSpikesSetup()
        {
            Customer c1 = Om.CreateCustomerWithOneAddress();
            Customer c2 = Om.CreateCustomerWithOneAddress();

            c2.AddAddress(Om.CreateAddress("ME5 8HU"));
            Customer c3 = Om.CreateCustomer();

            c3.Name = "Mervyn Ramos";
            Customer c4 = Om.CreateCustomer();

            c4.ShortCode = "009";

            _customersInDb = new List <Customer>();
            _customersInDb.AddRange(new[] { c1, c2, c3, c4 });

            Nh.InsertIntoDb(_customersInDb);
        }
示例#4
0
 public static Guid Insert(EntityBase entity)
 {
     return(Nh.InsertIntoDb(entity));
 }