static void Main(string[] args)
        {
            int id = 0;

            DataBase db = new DataBase("hubasky.ddns.net", "peet", "HP_TEST", "3306", "szoftech");

            using (MySqlConnection conn = new MySqlConnection(db.GetConnectionString()))
            {
                conn.Open();

                using (var context = new TestDb(conn, false))
                {
                    var persons = context.Persons.ToList();
                    foreach (Person person in persons)
                    {
                        Console.WriteLine("{0}, {1}, {2}", person.Id, person.Name, person.Phone);
                        id = person.Id + 1;
                    }

                    Person newPerson = new Person();
                    newPerson.Id = id;
                    Console.Write("Név: ");
                    newPerson.Name = Console.ReadLine();
                    Console.Write("Tel: ");
                    newPerson.Phone = Console.ReadLine();

                    context.Persons.Add(newPerson);
                    context.SaveChanges();

                }

                conn.Close();
            }

            Console.WriteLine("Nyomj egy billentyűt a kilépéshez.");
            Console.ReadKey();
        }
Пример #2
0
        static void Main(string[] args)
        {
            int id = 0;

            DataBase db = new DataBase("hubasky.ddns.net", "peet", "HP_TEST", "3306", "szoftech");

            using (MySqlConnection conn = new MySqlConnection(db.GetConnectionString()))
            {
                conn.Open();

                using (var context = new TestDb(conn, false))
                {
                    var persons = context.Persons.ToList();
                    foreach (Person person in persons)
                    {
                        Console.WriteLine("{0}, {1}, {2}", person.Id, person.Name, person.Phone);
                        id = person.Id + 1;
                    }

                    Person newPerson = new Person();
                    newPerson.Id = id;
                    Console.Write("Név: ");
                    newPerson.Name = Console.ReadLine();
                    Console.Write("Tel: ");
                    newPerson.Phone = Console.ReadLine();

                    context.Persons.Add(newPerson);
                    context.SaveChanges();
                }

                conn.Close();
            }

            Console.WriteLine("Nyomj egy billentyűt a kilépéshez.");
            Console.ReadKey();
        }