msgraph-sdk-dotnet icon indicating copy to clipboard operation
msgraph-sdk-dotnet copied to clipboard

Delta Queries access to @removed {Changed | Deleted}

Open eeegs opened this issue 1 year ago • 6 comments

Is your feature request related to a problem? Please describe.

When trying to use the Delta Queries results @removed may be returned in an item as a property to indicate it was deleted. I see no way to access this via the library.

Describe the solution you'd like Maybe at the DirectoryObject level a deleted status indicator.

enum DeletedStatus { Active, Changed, Deleted }

class DirectoryObject
{
...
public DeletedStatus Status { get; set; }
...
}

Describe alternatives you've considered Unless I'm missing something, I may have to drop the C# library as I need this feature.

Additional context

eeegs avatar Sep 20 '22 23:09 eeegs

Thanks for raising this @eeegs

As the property comes back in the response, you may be able to check for its presence in the additionalData bag using code similar to this.

if (directoryObject.AdditionalData.TryGetValue("@removed", out var removed))
{
    var reasonString = ((JsonElement)removed).TryGetProperty("reason", out var reason) ? reason.GetString() : string.Empty;
}

andrueastman avatar Sep 21 '22 06:09 andrueastman

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

msftbot[bot] avatar Sep 25 '22 07:09 msftbot[bot]

Thanks, I'll give it a go, but given the support for delta queries, I still think it might be better to have first class support for it.

eeegs avatar Sep 25 '22 08:09 eeegs

@andrueastman Hi, I don't know what extra feedback to give you.

eeegs avatar Sep 26 '22 09:09 eeegs

Hey @eeegs,

I was looking forward to the feedback from trying out the suggestion with fetching the property from the AdditionalData.

For context, due to the SDK being automatically generated, the shape of model classes takes a dependency of the API metadata which is found at https://graph.microsoft.com/v1.0/$metadata. As the metadata specifies that the delta will return a collection of DirectoryObject the metadata ideally needs also to also specify the @changed property or some other signal. Some extra work would need to be done on that front to update/transform the metadata for this to be added.

andrueastman avatar Sep 26 '22 11:09 andrueastman

Cool, give me a few days, I'm knee deep in other parts of the app and the Lego is all over the floor.

Regards,

Scott

eeegs avatar Sep 26 '22 12:09 eeegs