Exemplo n.º 1
0
#pragma warning disable EF1001 // Internal EF Core API usage.
        // Issue #16707
        private IUpdateEntry GetRootDocument(InternalEntityEntry entry)
        {
            var stateManager = entry.StateManager;
            var ownership    = entry.EntityType.FindOwnership();
            var principal    = stateManager.FindPrincipal(entry, ownership);

            if (principal == null)
            {
                if (_sensitiveLoggingEnabled)
                {
                    throw new InvalidOperationException(
                              CosmosStrings.OrphanedNestedDocumentSensitive(
                                  entry.EntityType.DisplayName(),
                                  ownership.PrincipalEntityType.DisplayName(),
                                  entry.BuildCurrentValuesString(entry.EntityType.FindPrimaryKey().Properties)));
                }

                throw new InvalidOperationException(
                          CosmosStrings.OrphanedNestedDocument(
                              entry.EntityType.DisplayName(),
                              ownership.PrincipalEntityType.DisplayName()));
            }

            return(principal.EntityType.IsDocumentRoot() ? principal : GetRootDocument(principal));
        }