Ejemplo n.º 1
0
 static Author GetAuthorByIdFind(int id)
 {
     using (Library_EntityFramEntities db = new Library_EntityFramEntities())
     {
         var au = db.Author.Find(id);
         Console.WriteLine(au.FirstName + " " + au.LastName);
         return(au);
     }
 }
Ejemplo n.º 2
0
 static Author GetAuthorById(int id)
 {
     using (Library_EntityFramEntities db = new Library_EntityFramEntities())
     {
         var author = (from s in db.Author
                       where s.Id == id
                       select s).Single();
         return(author);
     }
 }
Ejemplo n.º 3
0
 static Author GetAuthorByName1(string fname)
 {
     using (Library_EntityFramEntities db = new Library_EntityFramEntities())
     {
         var author = db.Author.Where((x) =>
                                      x.FirstName == fname).FirstOrDefault();
         Console.WriteLine("Result search: ");
         return(author);
     }
 }
Ejemplo n.º 4
0
        static void AddAuthor(Author author)
        {
            using (Library_EntityFramEntities db = new Library_EntityFramEntities())
            {
                db.Author.Add(author);
                db.SaveChanges();

                Console.WriteLine("New author added: " + author.LastName);
            }
        }
Ejemplo n.º 5
0
 static Author GetAuthorById1(int id)
 {
     using (Library_EntityFramEntities db = new
                                            Library_EntityFramEntities())
     {
         var author = db.Author.Where((x) =>
                                      x.Id == id).SingleOrDefault();
         return(author);
     }
 }
Ejemplo n.º 6
0
 static void GetAllAuthors()
 {
     using (Library_EntityFramEntities db = new Library_EntityFramEntities())
     {
         var au = db.Author.ToList();
         foreach (var a in au)
         {
             Console.WriteLine(a.FirstName + " " + a.LastName);
         }
     }
 }
Ejemplo n.º 7
0
 static void GetAllAuthorsSort()
 {
     using (Library_EntityFramEntities db = new Library_EntityFramEntities())
     {
         var au = (from a in db.Author
                   orderby a.LastName descending
                   select a).ToList();
         foreach (var a in au)
         {
             Console.WriteLine(a.FirstName + " " +
                               a.LastName);
         }
     }
 }
Ejemplo n.º 8
0
 static void GetAllAuthors(string c)
 {
     using (Library_EntityFramEntities db =
                new Library_EntityFramEntities())
     {
         var au = db.Author.Where((x) =>
                                  x.LastName.StartsWith(c)).ToList();
         foreach (var a in au)
         {
             Console.WriteLine(a.FirstName + " " +
                               a.LastName);
         }
     }
 }
Ejemplo n.º 9
0
 static void GetAllAuthors1(string c)
 {
     using (Library_EntityFramEntities db =
                new Library_EntityFramEntities())
     {
         var au = (from a in db.Author
                   where a.LastName.StartsWith(c)
                   select a).ToList();
         foreach (var a in au)
         {
             Console.WriteLine(a.FirstName + " " +
                               a.LastName);
         }
     }
 }