public static PhysicalPerson GetPhysicalPerson_ByID(int id)
        {
            try
            {
                using (dbRegistrationContext context = new dbRegistrationContext())
                {
                    var query = from p in context.PERSON
                                join pp in context.PHYSICALPERSON
                                on p.ID equals pp.PERSON_ID
                                where p.ID == id
                                select p;

                    PhysicalPerson ppr = new PhysicalPerson();

                    foreach (var item_p in query)
                    {
                        ppr.Id    = item_p.ID;
                        ppr.Name  = item_p.NAME;
                        ppr.Email = item_p.EMAIL;

                        foreach (var item_pp in item_p.PHYSICALPERSON)
                        {
                            ppr.Salary    = item_pp.SALARY;
                            ppr.DateBirth = item_pp.DATEBIRTH;
                            ppr.Genre     = item_pp.GENRE[0];
                        }
                    }
                    return(ppr);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public static List <PhysicalPerson> GetPhysicalPerson_SalaryUnderAVG()
        {
            {
                try
                {
                    using (dbRegistrationContext context = new dbRegistrationContext())
                    {
                        decimal avg_sal = context.PHYSICALPERSON.Average(p => p.SALARY);

                        var query = from p in context.PERSON
                                    join pp in context.PHYSICALPERSON
                                    on p.ID equals pp.PERSON_ID
                                    where pp.SALARY < avg_sal
                                    select p;

                        List <PhysicalPerson> list = new List <PhysicalPerson>();

                        foreach (var item_p in query)
                        {
                            PhysicalPerson ppr = new PhysicalPerson();

                            ppr.Id    = item_p.ID;
                            ppr.Name  = item_p.NAME;
                            ppr.Email = item_p.EMAIL;

                            foreach (var item_pp in item_p.PHYSICALPERSON)
                            {
                                ppr.Salary    = item_pp.SALARY;
                                ppr.DateBirth = item_pp.DATEBIRTH;
                                ppr.Genre     = item_pp.GENRE[0];
                            }

                            list.Add(ppr);
                        }
                        return(list);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
        public static List <PhysicalPerson> GetPhysicalPerson_ByName(string name)
        {
            try
            {
                using (dbRegistrationContext context = new dbRegistrationContext())
                {
                    var query = from p in context.PERSON
                                join pp in context.PHYSICALPERSON
                                on p.ID equals pp.PERSON_ID
                                where p.NAME.StartsWith(name)
                                select p;

                    List <PhysicalPerson> list = new List <PhysicalPerson>();

                    foreach (var item_p in query)
                    {
                        PhysicalPerson ppr = new PhysicalPerson();

                        ppr.Id    = item_p.ID;
                        ppr.Name  = item_p.NAME;
                        ppr.Email = item_p.EMAIL;

                        foreach (var item_pp in item_p.PHYSICALPERSON)
                        {
                            ppr.Salary    = item_pp.SALARY;
                            ppr.DateBirth = item_pp.DATEBIRTH;
                            ppr.Genre     = item_pp.GENRE[0];
                        }

                        list.Add(ppr);
                    }
                    return(list);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }