code View

id 4
Title EVI-CS06 /People with no appointment
Type evidenza
Highlight group filequery1003.cs, Evidenze
Description Persone senza appuntamenti
Code
           var q_uvu = db.d_events
                .AsNoTracking()
                .Where(x => x.event_type.ToLower() == "app_verify" && x.date_apt_exe == null)
                .Select(s => new { s.id_person, idApt = (string.IsNullOrEmpty(s.id_event) ? "" : "!") } ).Distinct();

        var qry1 = db.d_person.GroupJoin(q_uvu, a => a.id_person, b => b.id_person, (a, b) => new { a, b })
                             .Where(w => w.a.date_stopped == null)
                             .SelectMany(x => x.b.DefaultIfEmpty(), (a, b) => new
                             {
                                 a.a.id_person,
                                 a.a.id_dream,
                                 a.a.pe_surname,
                                 a.a.pe_name,
                                 a.a.pe_sex,
                                 a.a.pe_dob,
                                 a.a.date_started,
                                 b.idApt,
                                 a.a.pe_note
                             });

        var qry2 = db.d_events
                    .AsNoTracking()
                    .Where(w => w.event_type != "APP_VERIFY" && w.date_apt_exe == null )
                    .GroupBy(g => g.id_person)
                    .Select(s => new { id_person = s.Key });

        var qry = (from a in qry1
                   from d2 in qry2.Where(w => a.id_person == w.id_person).DefaultIfEmpty()
                   where
                     d2.id_person == null
                   select new
                   {
                       a.id_person,
                       a.idApt,
                       a.id_dream,
                       a.pe_surname,
                       a.pe_name,
                       a.pe_sex,
                       a.pe_dob,
                       a.date_started,
                       a.pe_note

                   }).AsEnumerable()
                   .Select(s => new
                   {
                       s.id_person,
                       s.idApt,
                       s.id_dream,
                       s.pe_surname,
                       s.pe_name,
                       s.pe_sex,
                       _data = (s.pe_dob.HasValue) ? s.pe_dob.Value.ToShortDateString() : "",
                       s.date_started,
                       s.pe_note
                   });


        dt = qry.ToDataTable();
        dt.TableName = "lst_data";

 

Ordine