English 中文(简体)
如何在 Linq 中使用选中的 many?
原标题:How to use selectmany in linq?

以下是我的Linq 查询

  var meetingIndividualQuery = meetingsList.SelectMany(o => o.Attendies.Distinct().Where(x => x.CompanyId == company.CompanyId));

我有下课课课

public class Meetings
    {
        public string IndustryCouncil { get; set; }
        public string MeetingType { get; set; }
        public string MeetingDescription { get; set; }
        public string MeetingDate { get; set; }
        public string MeetingHours { get; set; }
        public string MeetingHourlyValue { get; set; }
        public string MeetingTotal { get; set; }
        public List<Individual> Attendies { get; set; }
    }

有了上述查询,我正在得到正确的会议名称列表,但我如何能使用同样条件的相同查询来检索会议名称列表。请给我任何代码。

最佳回答

下列查询将退回至少有一名有公司身份证明的与会者的会议清单:

var query = meetingsList.Where(m => m.Attendies.Any(i => i.CompanyId == company.CompanyId));

在验证 anyny 之前,您还可以将 Distinct 应用到参与者

问题回答

暂无回答




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

热门标签