Saving object to repository : dataObject.Properties.Set("i_folder_id") vs dataObject.Relationships.Add()

496 Views Asked by At

I am using DFS.NET Productivity layer v6.7.

I have variables dataObject and repoFolderPath. I want to save dataObject inside the folder specified by the path repoFolderPath.

I can do this in two ways:

  1. By setting i_folder_id:

    dataObject.Properties.Set<String[]>("i_folder_id", new String[] { repoFolderPath } );
    
  2. By using DFS .NET API:

    ObjectPath objectPath = new ObjectPath(repoFolderPath);
    ObjectIdentity linkFolderIdentity = new ObjectIdentity(objectPath, repositoryName);
    ReferenceRelationship linkFolderRelationship = new ReferenceRelationship();
    linkFolderRelationship.Name = Relationship.RELATIONSHIP_FOLDER;
    linkFolderRelationship.Target = linkFolderIdentity;
    linkFolderRelationship.TargetRole = Relationship.ROLE_PARENT;
    dataObject.Relationships.Add(linkFolderRelationship);
    

Q. What difference it will make if I choose one above other apart from the fact that in first approach I can use i_folder_id and in second approach I can use repoFolderPath? Will the second set of lines ultimately result in setting i_folder_id, or will do something more in addition to it?

Obviously for saving dataObject to the repository I am doing following in both the cases:

DataPackage dataPackage = new DataPackage(dataObject);
OperationOptions operationOptions = null;
DataPackage resultPackage = objectService.Create(dataPackage, operationOptions);
1

There are 1 best solutions below

3
On

I am 99% sure that in this case when you create new object there is no difference between those two approaches, but for the sake of your vocation don't use first approach.

I did some research regarding relation types in my freshly installed repository. There is no relation type that would indicate some kind of connection between folder and objects linked to it. That just solidifies my assumption that there isn't anything else with linking object to folders aside from i_folder_id attribute.

As for the linking object to multiple folders - you just repeat lines you wrote for the first folder.