Esempio n. 1
0
 public ApiController(ILogger <ApiController> logger, SQLiteEF.PeopleContext context)
 {
     _logger  = logger;
     _context = context;
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            using (SQLiteEF.PeopleContext c = new SQLiteEF.PeopleContext())
            {
                List <SQLiteEF.Person> lst;
                //lst = c.People.ToList();
                //lst.ForEach(i => Console.WriteLine(i));


                //lst = c.People.Take(5).ToList();
                //lst.ForEach(i => Console.WriteLine(i));


                //lst = c.People.OrderBy(i => i.LastName).ToList();
                //lst.ForEach(i => Console.WriteLine(i));


                //lst = c.People.OrderBy(i => i.Gender).ThenBy(i => i.LastName).ToList();
                //lst.ForEach(i => Console.WriteLine(i));


                //lst = c.People.Where(i => i.Gender.Equals(1)).ToList();
                //lst.ForEach(i => Console.WriteLine(i));


                //lst = c.People.Where(i => i.Gender.Equals(1) && i.IsHealthy).ToList();
                //lst.ForEach(i => Console.WriteLine(i));


                //lst = c.People.Where(i => i.Gender.Equals(1) && i.IsHealthy).OrderBy(i => i.LastName).ToList();
                //lst.ForEach(i => Console.WriteLine(i));


                //var res = c.People.GroupBy(i => i.IsHealthy);
                //foreach (var item in res)
                //{
                //    Console.WriteLine($"IsHealthy {item.Key}");
                //    foreach (var item2 in item)
                //    {
                //        Console.WriteLine($"\t Navn: {item2.FirstName}");
                //    }
                //}

                //var p = c.People.Where(i => i.PersonId == 1).FirstOrDefault();
                //p.Height = 150;
                //c.SaveChanges();
                //lst = c.People.OrderBy(i => i.PersonId).ToList();
                //lst.ForEach(i => Console.WriteLine(i));

                SQLiteEF.Person person = new SQLiteEF.Person();
                person.FirstName   = "a";
                person.LastName    = "b";
                person.DateOfBirth = DateTime.Now;
                person.Gender      = 1;
                person.Height      = 180;
                person.IsHealthy   = true;
                c.People.Add(person);
                c.SaveChanges();

                //int id = person.PersonId;

                //Console.WriteLine($"Person oprettet med {id}");

                //var p = c.People.Where(i => i.PersonId == id).FirstOrDefault();

                //c.People.Remove(p);

                //c.SaveChanges();
            }
        }