John John
John John

Reputation: 1

ToDictionary error "Cannot apply indexing with [] to an expression of type 'method group'"

I have the following code inside my asp.net mvc web application :-

 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;
              }
          }
     }

But i am getting the following error :

Cannot apply indexing with [] to an expression of type 'method group

on the following code:

if (EXresource.ContainsKey[EXid.Value] )

Upvotes: 0

Views: 1265

Answers (1)

Ric
Ric

Reputation: 13248

change to:

if (EXresource.ContainsKey(EXid.Value))

Dictionary.ContainsKey()

Upvotes: 5

Related Questions