C# 左外连接

    internal class Patient
    {
        public int PType { get; set; }
        public string PatientName { get; set; }
    }

    internal class PatientType
    {
        public int PType { get; set; }
        public string PTypeName { get; set; }
    }

            var result2 = patients.GroupJoin(
                    patientTypes,
                    p => p.PType,
                    t => t.PType,
                    (p, t) => t.DefaultIfEmpty()
                        .Select(x => new { p.PatientName, x?.PTypeName }))
                .SelectMany(x => x).ToList();
posted @ 2022-03-30 17:04  ChasingDreams  阅读(62)  评论(0编辑  收藏  举报