private string GetFilteredQuery(string sql, BooksQueeryFilter filter = null)
        {
            var sqlBuilder = new SqlBuilder();

            var template = sqlBuilder.AddTemplate(sql);

            if (filter != null)
            {
                if (filter.Name != null)
                {
                    sqlBuilder.Where("Books.Title = @Title");
                }
                if (filter.AuthorId.HasValue)
                {
                    sqlBuilder.Where("Books.AuthorId = @AuthorId");
                }
            }

            return(template.RawSql);
        }
        public IEnumerable <BookWithAuthorDto> GetBooks(BooksQueeryFilter filter = null)
        {
            var sql = @"
                SELECT 
                    Books.Id,
                    Books.Title,
                    Authors.Name AS Author
                FROM
                    Books
                INNER JOIN
                    Authors ON Authors.Id = Books.AuthorId
                /**where**/
            ";

            sql = GetFilteredQuery(sql, filter);

            using (var conn = _db.OpenConnection())
            {
                return(conn.Query <BookWithAuthorDto>(sql, filter));
            }
        }