示例#1
0
        /// <summary>
        /// Returns an array of modified members that contain their current and original values.
        /// </summary>
        /// <param name="entity">The entity from which to get the array.</param>
        /// <returns>An array of modified members.</returns>
        public ModifiedMemberInfo[] GetModifiedMembers(TEntity entity)
        {
            if (entity == null)
            {
                throw Error.ArgumentNull("entity");
            }
            MetaType metaType = Context.Mapping.GetMetaType(entity.GetType());

            if ((metaType == null) || !metaType.IsEntity)
            {
                throw Error.EntityIsTheWrongType();
            }
            TrackedObject trackedObject = Context.Services.ChangeTracker.GetTrackedObject(entity);

            if (trackedObject != null)
            {
                return(trackedObject.GetModifiedMembers().ToArray());
            }
            return(new ModifiedMemberInfo[0]);
        }