You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tp1Entity/tp1/TestStub/Program.cs

40 lines
1.0 KiB

using Library;
using Library.DbContextLib;
using Library.Entities;
using Microsoft.Extensions.Options;
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
using (var context = new LibraryContext())
{
BookEntity chewie = new BookEntity("B3", "test", "test2");
BookEntity yoda = new BookEntity ("B4", "test", "test2");
BookEntity ewok = new BookEntity ("C5", "test", "test3");
context.BooksSet.Add(chewie);
context.BooksSet.Add(yoda);
context.BooksSet.Add(ewok);
context.SaveChanges();
}
using (var context = new LibraryContext())
{
foreach (var n in context.BooksSet)
{
Console.WriteLine($"{n.ID} - {n.Title}");
}
context.SaveChanges();
}
using (var context = new LibraryContext())
{
var eBooks = context.BooksSet.Where(b => b.Title.StartsWith("B")).First();
Console.WriteLine($"{eBooks.Title} (born in {eBooks.Author})");
eBooks.Title = "Wicket";
context.SaveChanges();
}