Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Update property
 /// </summary>
 /// <param name="id">Id</param>
 /// <param name="name">Property Name</param>
 /// <param name="value">Property Value</param>
 /// <returns>Entity</returns>
 public static T UpdateProperty <TProperty>(TKey id, string name, TProperty value)
 {
     return(UpdateProperty(id, Property <TProperty> .Create(name, value)));
 }