Example #1
0
        /// <summary>
        /// Update property
        /// </summary>
        /// <typeparam name="TProperty"></typeparam>
        /// <param name="id">Id</param>
        /// <param name="property">Property</param>
        /// <returns>Entity</returns>
        public static T UpdateProperty <TProperty>(TKey id, Property <TProperty> property)
        {
            using (var transaction = Session.BeginTransaction())
            {
                var entity = Session.Get <T>(id);

                Property.SetValue(entity, property);

                Session.SaveOrUpdate(entity);

                transaction.Commit();

                return(entity);
            }
        }
Example #2
0
        /// <summary>
        /// Update properties
        /// </summary>
        /// <param name="id">Id</param>
        /// <param name="properties"><see cref="IList{T}"/></param>
        /// <returns>Entity</returns>
        public static T UpdateProperties(TKey id, IList <Property <object> > properties)
        {
            using (var transaction = Session.BeginTransaction())
            {
                var entity = Session.Get <T>(id);

                foreach (var property in properties)
                {
                    Property.SetValue(entity, property);
                }

                Session.SaveOrUpdate(entity);

                transaction.Commit();

                return(entity);
            }
        }