예제 #1
0
        /// <summary>
        /// Update modified fields
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="pEntity"></param>
        /// <param name="pEntity2"></param>
        /// <param name="pContext"></param>
        public static void UpdateModifiedFields <T>(this T pEntity, T pEntity2, ref FilesDbContext pContext)
        {
            var entry = pContext.Entry(pEntity);

            foreach (var prop in entry.Properties)
            {
                var value = pEntity2.GetType().GetProperty(prop.Metadata.Name).GetValue(pEntity2);
                if (value != null)
                {
                    prop.CurrentValue = value;
                }
            }
        }
예제 #2
0
 public void Update(T obj)
 {
     db.Entry(obj).State = EntityState.Modified;
 }