示例#1
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(Name.Text))
            {
                var author = new Author()
                {
                    Name = Name.Text
                };

                creatorDAO.Add(author);
            }
        }
        static void Main(string[] args)
        {
            using (var sqlConnection =
                       new NpgsqlConnection("Host=localhost;Username=postgres;Password=postgres;Database=dotnet"))
            {
                sqlConnection.Open();
                AuthorDAO authorDAO = new AuthorDAO(sqlConnection);

                Author myAuthor = new Author();
                myAuthor.Name = "Arthur";
                authorDAO.Add(myAuthor);

                var authors = authorDAO.FindByName("Arthur");
                foreach (var author in authors)
                {
                    Console.WriteLine(author.Name);
                }

                authorDAO.DeleteAll();

                sqlConnection.Close();
            }
        }
 public ResultContainer AddAuthor(Author author)
 {
     return(_authorDAO.Add(author));
 }