English 中文(简体)
LINQ 任何(a) 争论与参数数据类型问题
原标题:LINQ Any() argument versus parameter data type issues
  • 时间:2011-07-28 15:44:20
  •  标签:
  • c#
  • linq

我的物体有直观型参数,称为baan_cat_fam_code。 下面的法典是我试图在问询中找到所有在称为<>catFamCd的通用说明清单上存在的项目。

query = query.Where(r => r.baan_cat_family_code.Any(s => catFamCode.Contains(s)));

问题是,这只得 compile——我犯了一个错误,指出:

"Argument type  char  is not assignable to parameter type  string "

出于某种原因,定点s被归类为果园。 因此,我附上.ToString()在中的论点。 含有方法。 然而,当《守则》生效时,当问答结果受名单框的约束时,我会遇到以下例外。

"The argument  value  was the wrong type. Expected  System.Char . Actual  System.String ."

这使我对我的领导感到欣慰。 任何援助都将受到高度赞赏。

感谢!

最佳回答

您再次提出的问题是:baan_cat_family_codestring的,实施IE amountable<char>。 页: 1 任何基本上都说

  • Is the predicate true for any char in this string

你们真正想要问的是:

  • Is this string in the list catFamCode

询问后一种情况

query = query.Where(r => catFamCode.Contains(r.baan_cat_family_code));
问题回答

页: 1

您应当这样做:

query = query.Where(r => catFamCode.Contains(r.baan_cat_family_code));




相关问题
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. ...

热门标签