static void Main(string[] args)
        {
            var listaProfesores = CrearLista();
            var db = new InstitucionDB();

            db.Profesores.AddRange(listaProfesores);
            db.SaveChanges();

            //var subconjunto = from prof in db.Profesores
            //                  where prof.Nombre.StartsWith("J")
            //                  select prof;

            //foreach (var item in subconjunto)
            //{

            //    item.CodigoInterno = "STARTS_WITH_J";
            //    Console.WriteLine(item.Nombre);
            //}

            //db.SaveChanges();

            Console.WriteLine("Cuantos JM hay ??" + db.Profesores.Where((p) => p.Nombre == "Jose Mauricio").Count());

            var profesorBorrable = (from p in db.Profesores
                                    where p.Nombre == "Jose Mauricio"
                                    select p).FirstOrDefault();

            db.Profesores.Remove(profesorBorrable);
            db.SaveChanges();
            Console.WriteLine("Cuantos JM quedaron ??" + db.Profesores.Where((p) => p.Nombre == "Jose Mauricio").Count());

            Console.ReadLine();
        }
Example #2
0
        static void Main(string[] args)
        {
            var listaProfesores = CrearLista();
            var db = new InstitucionDB();

            //db.Profesores.AddRange(listaProfesores);
            //db.SaveChanges();

            //var subconjunto = from prof in db.Profesores
            //                  where prof.Nombre.StartsWith("J")
            //                  select prof;

            //foreach (var item in subconjunto)
            //{
            //    item.CodigoInterno = "STARTS_WITH_J";
            //    Console.WriteLine(item.Nombre);
            //}

            //db.SaveChanges();

            var profesorBorrable = (from p in db.Profesores
                                    where p.Nombre == "Jeronimo"
                                    select p);



            Console.ReadLine();
        }
Example #3
0
        public static void ListaProfesoresDb()
        {
            var listaProfesores = CrearLista();
            var db = new InstitucionDB();

            db.Profesores.AddRange(listaProfesores);
            db.SaveChanges();
        }
Example #4
0
        static void Main(string[] args)
        {
            var profe = new Profesor()
            {
                Id = 4, Nombre = "oscar", Apellido = "perez", CodigoInterno = "Profe_smart"
            };

            var trasmitter = new TransmisorDeDatos();

            //asigancion de eventos
            // multicast delegate

            trasmitter.InformationSend += Trasmitter_InformationSend;
            trasmitter.InformationSend += (obj, evtargs) => { Console.WriteLine("segundo evento casteado"); };
            //trasmitter.FormatearYEnviar(profe, formatter,"Alex");
            //trasmitter.FormatearYEnviar(profe, formatter2, "Alex");

            // lambda functions
            trasmitter.FormatearYEnviar(profe, (s) => new string(s.Reverse().ToArray <char>()), "Alex");
            trasmitter.FormatearYEnviar(profe, formatter2, "Alex");

            // quitando eventos
            trasmitter.InformationSend -= Trasmitter_InformationSend;
            trasmitter.FormatearYEnviar(profe, formatter, "Alex");

            Console.WriteLine("Manipulacion de documentos");

            var listaProfesores = new List <Profesor>();

            string[] lineas = File.ReadAllLines("./Files/Profesores.txt");

            int localId = 0;

            foreach (var line in lineas)
            {
                listaProfesores.Add(new Profesor()
                {
                    Nombre = line, Id = localId++
                });
            }

            foreach (var prof in listaProfesores)
            {
                Console.WriteLine(prof.Nombre);
            }

            //binary files
            var archivo = File.Open("profesBinarios.bin", FileMode.OpenOrCreate);

            var binaryFile = new BinaryWriter(archivo);

            foreach (var prof in listaProfesores)
            {
                //var bytesNombre = Encoding.UTF8.GetBytes(prof.Nombre);
                //archivo.Write(bytesNombre, 0, bytesNombre.Length);

                binaryFile.Write(profe.Nombre);
                binaryFile.Write(profe.Id);
            }

            //liberar memoria
            binaryFile.Close();
            archivo.Close();


            Console.WriteLine("Conexion a base de Datos con Entity Frameworks");

            var db = new InstitucionDB();

            db.Profesores.AddRange(listaProfesores);
            db.SaveChanges();


            Console.ReadLine();
        }