Sami Parkar
Sami Parkar

Reputation: 29

The type argument for method cannot be inferred from the usage

I am new in programming, when i write a code for particular function, i find this below error. Please help me to solve this error.

public IList<ScoreCardListItemTO> UpdateDate(bool IsScoreCardUpdate, bool IsInputHeaderUpdate, long ScoreCardId,
    long ScoreCardSubmitResponseId, long QuestionId, DateTime UpdatedOn)
{
    var parameters = new[]
    {
        new ObjectParameter("IsScoreCardUpdate", IsScoreCardUpdate ),
        new ObjectParameter("IsInputHeaderUpdate", IsInputHeaderUpdate ),
        new ObjectParameter("ScoreCardId", ScoreCardId ),
        new ObjectParameter("ScoreCardSubmitResponseId", ScoreCardSubmitResponseId ),
        new ObjectParameter("QuestionId", QuestionId),
        new ObjectParameter("UpdatedOn", UpdatedOn),
    };

    ObjectResult items = ExecuteEqmFunction("SyncUpdateOnColumn", string.Empty );
    return items;
}

the error show at this line

ObjectResult items = ExecuteEqmFunction("SyncUpdateOnColumn", string.Empty );
return items;

The error state that

Error 42 The type arguments for method 'EQM.DataLayer.EqmRepository.ExecuteEqmFunction(string, string, params System.Data.Objects.ObjectParameter[])' cannot be inferred from the usage. Try specifying the type arguments explicitly.

Upvotes: 1

Views: 2776

Answers (2)

Zein Makki
Zein Makki

Reputation: 30052

As I found in the definition of the error when editing your question because it is not visible otherwise.

The method ExecuteEqmFunction<T> is generic and expects a type T. Generic method infers the type only from the arguments you pass. Since you don't have any argument with type T, you need to specify that type explicitly:

 ObjectResult items = ExecuteEqmFunction<ObjectResult>("SyncUpdateOnColumn", 
                                                                 string.Empty, parameters);

Assuming T is the return type for that method.

Upvotes: 2

Andrew Cheong
Andrew Cheong

Reputation: 30293

Just as it says , ExecuteEqmFunction is expecting 3 or 4 arguments, of which you supplied the first 2.

Try

ObjectResult items = ExecuteEqmFunction("SyncUpdateOnColumn", string.Empty, parameters);

I lack context, but I don't know why else you'd build parameters in that scope if not to supply it.

Upvotes: 2

Related Questions