ArcGIS Pro 3.5 API Reference Guide
ArcGIS.Desktop.Editing Namespace / EditOperation Class / Create Method / Create(MapMember,KnowledgeGraphDocumentDescription) Method
The map member representing the Document named type.
A description of the document record to create.
Example

In This Topic
    Create(MapMember,KnowledgeGraphDocumentDescription) Method
    In This Topic
    Creates a new row in the Knowledge Graph Document table for the specified properties in the KnowledgeGraphDocumentDescription.
    Syntax

    Parameters

    documentMapMember
    The map member representing the Document named type.
    documentDescription
    A description of the document record to create.

    Return Value

    A RowToken object that represents the row to be created.
    Exceptions
    ExceptionDescription
    documentMapMember cannot be null.
    documentDescription cannot be null.
    The document path is an invalid path.
    The documentMapMember is not part of a Knowledge Graph, the Knowledge Graph does not support documents or documentMapMember is not the Knowledge Graph document type.
    Remarks
    If a document is specified, the name, url, contentType, title, fileExtension and text fields are auto populated from the document.
    Example
    Create an Entity, a Document, a HasDocument and a Provenance record
    await QueuedTask.Run(() =>
    {
      //Instantiate an operation for the Create
      var edit_op = new EditOperation()
      {
        Name = "Create a records",
        SelectNewFeatures = true
      };
    
      // create the entity
      var personToken = edit_op.Create(personLayer, personAtts);
    
      // create the document
      var kgDocDesc = new KnowledgeGraphDocumentDescription(@"D:\Data\BirthCertificate.jpg");
      var docToken = edit_op.Create(docLayer, kgDocDesc);
    
      // create RowHandles from the returned RowTokens
      var personHandle = new RowHandle(personToken);
      var docHandle = new RowHandle(docToken);
    
      // create the "hasDocument" relationship
      var rd = new KnowledgeGraphRelationshipDescription(personHandle, docHandle);
      edit_op.Create(hasDocLayer, rd);
    
      // create the provenance record for the person entity using the document entity
      // provenance record is on the "name" field 
      var pd = new KnowledgeGraphProvenanceDescription(personHandle, "name", docHandle, "", "comments");
      edit_op.Create(pd);
    
      // execute - create all the entities and relationship rows _together_
      edit_op.Execute();
    });
    
    Create a Document Record 2
    internal async void AddDocumentRecord2()
    {
    
      await QueuedTask.Run(() =>
      {
        using (var kg = GetKnowledgeGraph())
        {
    
          var propInfo = kg.GetPropertyNameInfo();
          if (!propInfo.SupportsDocuments)
            return false;
    
          var edit_op = new EditOperation()
          {
            Name = "Create Document Example",
            SelectNewFeatures = true
          };
    
          var doc_entity_name = propInfo.DocumentTypeName;
          var hasdoc_rel_name = GetHasDocumentTypeName(kg.GetDataModel());
    
          //Document can also be FeatureClass
          var doc_tbl = kg.OpenDataset<Table>(doc_entity_name);
          var doc_rel_tbl = kg.OpenDataset<Table>(hasdoc_rel_name);
    
          //This is the document to be added...file, image, resource, etc.
          var url = @"E:\Data\Temp\HelloWorld.txt";
    
          // create the KnowledgeGraphDocumentDescription
          var kgDocDesc = new KnowledgeGraphDocumentDescription(url);
    
          // if there is a geometry use the following ctor
          // var kgDocDesc = new KnowledgeGraphDocumentDescription(url, doc_location);
    
          // if you have additional custom attributes 
          //var customDocAtts = new Dictionary<string, object>();
          //customDocAtts.Add("custom_attrib", "Foo");
          //customDocAtts.Add("custom_attrib2", "Bar");
          //var kgDocDesc = new KnowledgeGraphDocumentDescription(url, null, customDocAtts);
    
          // add additional properties if required
          kgDocDesc.Keywords = @"text,file,example";
          
          /// The Create method will auto-populate the Url, Name, FileExtension and contentType fields of the document row
          /// from the path supplied.  
          var rowToken = edit_op.Create(doc_tbl, kgDocDesc);
    
          //Get the entity whose document this is...
          var org_fc = kg.OpenDataset<FeatureClass>("Organization");
          var qf = new QueryFilter()
          {
            WhereClause = "name = 'Acme'",
            SubFields = "*"
          };
          var origin_org_id = Guid.Empty;
          using (var rc = org_fc.Search(qf))
          {
            if (!rc.MoveNext())
              return false;
            origin_org_id = rc.Current.GetGlobalID();//For the relate
          }
    
          // set up the row handles
          var originHandle = new RowHandle(org_fc, origin_org_id);    // entity
          var destinationHandle = new RowHandle(rowToken);            // document
    
          // create the KnowledgeGraphRelationshipDescription
          var rd = new KnowledgeGraphRelationshipDescription(originHandle, destinationHandle);
    
          // if you have additional custom attributes for the "HasDocument" relationship
          //var customHasDocAtts = new Dictionary<string, object>();
          //customHasDocAtts.Add("custom_attrib", "Foo");
          //customHasDocAtts.Add("custom_attrib2", "Bar");
          //var rd = new KnowledgeGraphRelationshipDescription(originHandle, destinationHandle, customHasDocAtts);
    
          // create the relate record using the same edit operation
          edit_op.Create(doc_rel_tbl, rd);
    
          //Call execute to create all the entities and relationship rows _together_
          return edit_op.Execute();
        }
        return false;
      });
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.5 or higher.
    See Also