English 中文(简体)
错误:Cannot将Mlambda的表述转换成型号,因为它不是代表型
原标题:Error: Cannot convert lambda expression to type int because it is not a delegate type
  • 时间:2012-04-11 07:14:31
  •  标签:
  • 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);
}

我正在发现这一错误:

不能将《玛尔布达》的表述转换成型号,因为它不是代表的类型。 C: NewEAccreditation.DataQueriesProgramsExtensions.Generated.cs

我怎么能加以纠正?

问题回答

你把你的方法是延伸方法,因此,就你的榜样而言,你可以忽略方法声明的第一个参数。

因此,你关切的唯一参数是第二个参数:int pKProgramID

当你称之为这一方法时(主动地),它期望有一席之地,但你正在通过一名代表(p=>p.PKProgram)。 ID = pKProgramID

而且,正如雷蒙·陈在评论中指出的那样,你的方法是令人厌恶的,因此,你可能会给你带来更多的痛苦!

不存在内在的上游删除。 你们必须使用:

table.DeleteAllOnSubmit(table.Where(p => p.PKProgramID == pKProgramID));

或自我们担任PK以来是独特的:

var record = table.SingleOrDefault(p => p.PKProgramID == pKProgramID);
if(record != null) table.DeleteOnSubmit(record);

当然,你还需要在某个时候就具体情况制定<条码>。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签