Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot convert lambda expression to type 'int' because it is not a delegate type

Tags:

c#

This is the source code( I am using CodeSmith Tools):

public static int Delete(this System.Data.Linq.Table<EAccredidation.Data.Programs> table, int pKProgramID)
{
    return table.Delete(p => p.PKProgramID == pKProgramID);
}

I am getting this error:

Cannot convert lambda expression to type 'int' because it is not a delegate type C:\Projects\New\EAccreditation.Data\Queries\ProgramsExtensions.Generated.cs

How can I fix it?

like image 528
Dodo V Avatar asked Apr 11 '12 07:04

Dodo V


1 Answers

You've stipulated your method as an extension method, so for the purposes of your example, you can ignore the first parameter on the method declaration.

Therefore, the only parameter you are concerned with is the second, int pKProgramID.

When you call this method (recuirsively) it expects an int, but you are passing a lambda delegate (p => p.PKProgramID == pKProgramID)

And, as Raymond Chen intimated in his comment, your method is recursive, so you may have further pain ahead of you!

like image 143
James Wiseman Avatar answered Oct 16 '22 10:10

James Wiseman