예제 #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);
     }
 }
예제 #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);
     }
 }
예제 #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);
     }
 }
예제 #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);
            }
        }
예제 #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);
     }
 }
예제 #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);
         }
     }
 }
예제 #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);
         }
     }
 }
예제 #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);
         }
     }
 }
예제 #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);
         }
     }
 }