ToDictionary错误"不能对'方法group'"类型的表达式应用[]索引

本文关键字:quot 应用 表达式 索引 方法 不能 错误 ToDictionary group 类型 | 更新日期: 2023-09-27 17:51:08

我有以下代码在我的asp.net mvc web应用程序:-

 public void syncWithEX()
 {
     var EXresource = entities.Resources.Select(g => new
     {
         EXID = g.RESOURCEID,
         CurrentEXSiteID = g.ResourceLocation.SITEID
     }).ToDictionary(a => a.EXID, a => a.CurrentEXSiteID);
     var technology = ITSys.Technologies.Select(g => new
     {
          ID = g.TechnologyID,
          EXID = g.EXID
     }).ToDictionary(a => a.ID, a => a.EXID);
     var server = ITSys.ITSYSServers.Where(a => !a.Technology.IsDeleted && a.Technology.IsCompleted);
     foreach (var s in server)
     {
          long? EXid = technology[s.ITSYSServerID];
          if (EXresource.ContainsKey[EXid.Value] )
          {
              long? CurrentEXsiteid = EXresource[EXid.Value];
              if (CurrentEXsiteid != s.EXSiteID)
              {
                   s.EXSiteID = CurrentEXsiteid.Value;
                   ITSys.Entry(s).State = EntityState.Modified;
              }
          }
     }

但是我得到以下错误:

不能对'method group

类型的表达式应用[]索引

在下面的代码:

if (EXresource.ContainsKey[EXid.Value] )

ToDictionary错误"不能对'方法group'"类型的表达式应用[]索引

改成:

if (EXresource.ContainsKey(EXid.Value))

Dictionary.ContainsKey ()

相关文章: