Reputation: 859
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var delta = await graphClient.Users
.Delta()
.Request()
.Select("displayName,jobTitle,mobilePhone")
.GetAsync();
I noticed this, is there an easier way to do? Like Select("all property")
.
Upvotes: 1
Views: 807
Reputation: 667
Please try this one to get All :
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var users = await graphClient.Users
.Request()
.GetAsync();
Also Just to add more flavor, You also write your queries like this :
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var users = await graphClient.Users
.Request()
.Filter("mail eq '[email protected]'")
.Select( e => new {
e.DisplayName,
e.Mail
})
.GetAsync();
Here you can pass filter criteria if you want to apply. In select clause you can mention the columns which you wanted in output but if you not providing anything in select will give you all.
Microsoft Link for more details : Link
Upvotes: 1
Reputation: 20823
You can create own helper method that will use reflection to get all properties of type you need and create a select statement from these properties.
public static class Helper
{
public static IUserDeltaRequest SelectAll(this IUserDeltaRequest request)
{
var value = string.Join(",", typeof(User).GetProperties().Where(x => x.PropertyType == typeof(string)).Select(x => x.Name));
return request.Select(value);
}
}
I select only properties of type string.
var delta = await graphClient.Users
.Delta()
.Request()
.SelectAll()
.GetAsync();
Upvotes: 1