如何将@ microsoft.graph.conflictBehavior直接指定到OneDrive SDK调用中

时间:2017-08-29 03:39:36

标签: c# microsoft-graph onedrive

Previous question继上一个问题之后,

有没有办法可以将@microsoft.graph.conflictBehavior注释直接添加到SDK调用中,而不是在foldertoCreate对象中指定它?

var foldertoCreate = new DriveItem {
    Name = $"TestFolder",
    Folder = new Folder (),
    AdditionalData = new Dictionary<string, object> { 
        { "@microsoft.graph.conflictBehavior", "rename" }
    },
};

// somewhere in the below call

var newFolder = await _graphClient.Drive
    .Items["MyParent_Item_Id"]
    .Children
    .Request ()
    .AddAsync (foldertoCreate);

1 个答案:

答案 0 :(得分:1)

如果您只是想要整合代码,可以使用单个调用创建更加友好的呼叫:

var newFolder = await _graphClient.Drive.Items["MyParent_Item_Id"].Children.Request ().AddAsync (new DriveItem () {
    Name = $"TestFolder",
    Folder = new Folder (),
    AdditionalData = new Dictionary<string, object> { { "@microsoft.graph.conflictBehavior", "rename" } }
});