Пример #1
0
        public Author GetAuthorByID(int id)
        {
            string Query = $"SELECT Authors.ID, Authors.Name, Authors.DateOfBirth, Authors.Info FROM Authors WHERE [Authors].ID = @AuthorID";
            List <KeyValuePair <string, string> > Params = new List <KeyValuePair <string, string> >();

            Params.Add(new KeyValuePair <string, string>("AuthorID", id.ToString()));
            DataSet Result = this.ExecuteSQL(Query, Params);
            Author  A      = null;

            if (Result != null)
            {
                A = DataSetParser.DataSetToAuthor(Result, 0);
            }
            return(A);
        }
Пример #2
0
        public List <Author> GetAllAuthors()
        {
            string Query = "SELECT ID, Name, DateOfBirth, Info FROM Authors WHERE Name IS NOT NULL";
            List <KeyValuePair <string, string> > Params = new List <KeyValuePair <string, string> >();
            DataSet Results = this.ExecuteSQL(Query, Params);

            List <Author> Authors = new List <Author>();

            if (Results != null)
            {
                for (int i = 0; i < Results.Tables[0].Rows.Count; i++)
                {
                    Author a = DataSetParser.DataSetToAuthor(Results, i);
                    Authors.Add(a);
                }
            }
            return(Authors);
        }