none
Cannot implicty convert 'System.Guid' to Systems.Threading.Tasks.Task<System.Guid>' Error RRS feed

  • Question

  • I am getting the above error can someone tell me what I have wrong in the code below?  Thanks.

      public  Task<Guid> GetPartyRoleTypeIdAsync(Guid partyId, Guid addressId)
      {
       Guid result = System.Guid.Empty;
       try
       {
        var addressParty =  cwmContext.AddressParties.Where(a => a.PartyID == partyId && a.AddressID == addressId && a.Inactive == false).First() ?? new AddressParty();
        result =  addressParty.RoleTypeId ?? Guid.Empty;
       }
       catch (Exception ex)
       {
        logger.Error("Unexpected exception caught while retrieving the Activity Party Role Type Id for Party Id: " + partyId + " and Address Id: " + addressId + ".", ex);
       }
       return result;
      }

    Monday, July 15, 2019 4:16 PM

Answers

  • Depending on circumstances, try this:

     

    public async Task<Guid> GetPartyRoleTypeIdAsync( Guid partyId, Guid addressId )

    {

       Guid result = System.Guid.Empty;

       . . .

       return result;

    }

     

    or this:

     

    public Task<Guid> GetPartyRoleTypeIdAsync( Guid partyId, Guid addressId )

    {

       Guid result = System.Guid.Empty;

       . . .

       return Task.FromResult( result );

    }

    • Marked as answer by mrbill65 Monday, July 15, 2019 6:47 PM
    Monday, July 15, 2019 5:04 PM

All replies

  • Depending on circumstances, try this:

     

    public async Task<Guid> GetPartyRoleTypeIdAsync( Guid partyId, Guid addressId )

    {

       Guid result = System.Guid.Empty;

       . . .

       return result;

    }

     

    or this:

     

    public Task<Guid> GetPartyRoleTypeIdAsync( Guid partyId, Guid addressId )

    {

       Guid result = System.Guid.Empty;

       . . .

       return Task.FromResult( result );

    }

    • Marked as answer by mrbill65 Monday, July 15, 2019 6:47 PM
    Monday, July 15, 2019 5:04 PM
  • Thanks, the second one worked.
    Monday, July 15, 2019 6:47 PM