C# MS Graph API v1.0中查找用户时的变量插值问题

C# MS Graph API v1.0中查找用户时的变量插值问题,c#,azure-active-directory,microsoft-graph-api,interpolation,C#,Azure Active Directory,Microsoft Graph Api,Interpolation,我正在使用以下代码搜索用户详细信息: var users2 = await graphServiceClient.Users. .Request() .Filter("startswith(displayName,'Robert')") .Select(u => new { u.DisplayName, u.MobilePhone, u.UserPrincipalName }).GetAsync(); 它可以工作,但当我

我正在使用以下代码搜索用户详细信息:

 var users2 = await graphServiceClient.Users.
   .Request()
   .Filter("startswith(displayName,'Robert')")
   .Select(u => new {
       u.DisplayName,
       u.MobilePhone,
       u.UserPrincipalName
   }).GetAsync();
它可以工作,但当我使用下面的代码并尝试将用户显示名称存储在字符串中,然后运行查询时,它返回null

 string dispName = mem.DisplayName;

    var users2 = await graphServiceClient.Users
   .Request()
   .Filter("startswith(displayName,'{dispName}')")
   .Select(u => new {
       u.DisplayName,
       u.MobilePhone,
       u.UserPrincipalName
   })
   .GetAsync();
我也试过使用${dispName},但不起作用。
请帮忙。

根据要求,它应该是这样的


请参阅了解更多信息。

您没有插值任何内容-插值字符串以$-
$“startswith(displayName,{dispName}')”开头。
-请参见此处-不是变量本身,而是整个字符串。@Charleh是的,它可以工作。谢谢。
    string dispName = mem.DisplayName;

    var users2 = await graphServiceClient.Users
   .Request()
   .Filter($"startswith(displayName,'{dispName}')")
   .Select(u => new {
       u.DisplayName,
       u.MobilePhone,
       u.UserPrincipalName
   })
   .GetAsync();