Getting Started With dotConnect for FreshBooks

Below are some resources to help you maximize your experience with dotConnect for FreshBooks

dotConnect for FreshBooks is a high-performance ADO.NET data provider with ORM support, offering fast and encrypted access to FreshBooks data for application development.

  • EF Core, Dapper, and NHibernate ORM support
  • Local SQL engine with support for SQL-92
  • Broad compatibility with various .NET platforms and versions
  • Full compliance with ADO.NET
  • Integration with Visual Studio

Code examples

using Devart.Data.FreshBooks;

namespace FreshBooksConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString = "Authentication Type=OAuthInteractive;Company Name=Sapuk;License key=**********";

            try
            {
                using (FreshBooksConnection connection = new FreshBooksConnection(connectionString))
                {
                    connection.Open();
                    Console.WriteLine("Connection successful.");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred: " + ex.Message);
            }
        }

    }
}
PM> Install-Package Devart.Data.FreshBooks
using Devart.Data.FreshBooks;

namespace FreshBooksConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString = "API Version=Alpha;" +
                "Client Id=*****;" +
                "Client Secret=*****;" +
                "Access Token=*****;" +
                "Refresh Token=*****;" +
                "Company Name=*****" +
                "License key=**********";

            try
            {
                using (FreshBooksConnection connection = new FreshBooksConnection(connectionString))
                {
                    connection.Open();
                    Console.WriteLine("Connection successful.");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred: " + ex.Message);
            }
        }

    }
}
PM> Install-Package Devart.Data.FreshBooks
using System.Data;
using Devart.Data.FreshBooks;

string connectionString = "Authentication Type=OAuthInteractive;Company Name=*****;License key=**********";

try
{
    using (FreshBooksConnection connection = new FreshBooksConnection(connectionString))
    {
        connection.Open();
        Console.WriteLine("Connection successful.");

        string sql = "SELECT * FROM Client";

        using (FreshBooksCommand command = new FreshBooksCommand(sql, connection))
        using (FreshBooksDataAdapter adapter = new FreshBooksDataAdapter(command))
        {
            DataTable clientTable = new DataTable();
            adapter.Fill(clientTable);

            foreach (DataRow row in clientTable.Rows)
            {
                foreach (DataColumn column in clientTable.Columns)
                {
                    Console.Write($"{column.ColumnName}: {row[column] ?? "N/A"} | ");
                }
                Console.WriteLine();
            }

            Console.WriteLine($"\nTotal rows: {clientTable.Rows.Count}");
        }
    }
}
catch (Exception ex)
{
    Console.WriteLine("An error occurred: " + ex.Message);
}
PM> Install-Package Devart.Data.FreshBooks
using System;
using System.Linq;

namespace FreshBooksEFCore
{
    class Program
    {
        static void DisplayClients()
        {
            using (var context = new FreshBooksModel())
            {
                var clients = context.Client
                    .Select(t => new {
                        t.Id,
                        t.Username,
                        t.CurrencyCode,
                        t.Email,
                        t.MobilePhone,
                        t.FirstName,
                        t.LastName,
                        t.Language,
                        t.Organization,
                        t.PrimaryCity,
                        t.PrimaryCountry,
                        t.PrefersEmail,
                        t.LastActivity,
                        t.LastLogin,
                        t.Updated,
                        t.State
                    })
                    .ToList();

                foreach (var client in clients)
                {
                    Console.WriteLine($"Id: {client.Id}");
                    Console.WriteLine($"Username: {client.Username}");
                    Console.WriteLine($"Currency Code: {client.CurrencyCode}");
                    Console.WriteLine($"Email: {client.Email}");
                    Console.WriteLine($"Mobile Phone: {client.MobilePhone}");
                    Console.WriteLine($"First Name: {client.FirstName}");
                    Console.WriteLine($"Last Name: {client.LastName}");
                    Console.WriteLine($"Language: {client.Language}");
                    Console.WriteLine($"Organization: {client.Organization}");
                    Console.WriteLine($"Primary City: {client.PrimaryCity}");
                    Console.WriteLine($"Primary Country: {client.PrimaryCountry}");
                    Console.WriteLine($"Prefers Email: {client.PrefersEmail}");
                    Console.WriteLine($"Last Activity: {client.LastActivity?.ToString("yyyy-MM-dd HH:mm:ss") ?? "N/A"}");
                    Console.WriteLine($"Last Login: {client.LastLogin?.ToString("yyyy-MM-dd HH:mm:ss") ?? "N/A"}");
                    Console.WriteLine($"Updated: {client.Updated?.ToString("yyyy-MM-dd HH:mm:ss") ?? "N/A"}");
                    Console.WriteLine($"State: {client.State}");
                    Console.WriteLine(new string('-', 20));
                }
            }
        }

        static void Main(string[] args)
        {
            try
            {
                DisplayClients();
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred: " + ex.Message);
            }
        }
    }
}
PM> Install-Package Devart.Data.FreshBooks
using System;
using System.Data;
using Devart.Data.FreshBooks;

namespace FreshBooksConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString = "Authentication Type=OAuthInteractive;Company Name=*****;License key=**********";

            try
            {
                using (FreshBooksConnection connection = new FreshBooksConnection(connectionString))
                {
                    connection.Open();
                    Console.WriteLine("Connection successful.");

                    // Insert new client
                    string insertSql = @"INSERT INTO Client
                        (Username, CurrencyCode,
                         Email, Fax, HomePhone, MobilePhone, FirstName, LastName,
                         Language, Note, Organization, State)
                        VALUES
                        ('johndoe', 'USD',
                         '[email protected]', '555-0101', '555-0102', '555-0103',
                         'John', 'Doe', 'en', 'New client', 'Example Corp', 'active')";

                    using (FreshBooksCommand insertCommand = new FreshBooksCommand(insertSql, connection))
                    {
                        int rowsAffected = insertCommand.ExecuteNonQuery();
                        Console.WriteLine($"Insert successful. Rows affected: {rowsAffected}");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred: " + ex.Message);
            }
        }
    }
}
PM> Install-Package Devart.Data.FreshBooks
using System;
using System.Data;
using Devart.Data.FreshBooks;

namespace FreshBooksConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString = "Authentication Type=OAuthInteractive;Company Name=*****;License key=**********";

            try
            {
                using (FreshBooksConnection connection = new FreshBooksConnection(connectionString))
                {
                    connection.Open();
                    Console.WriteLine("Connection successful.");

                    using (FreshBooksDataAdapter adapter = new FreshBooksDataAdapter("SELECT * FROM Client WHERE 1=0", connection))
                    {
                        DataTable clientTable = new DataTable();
                        adapter.Fill(clientTable);

                        DataRow newRow = clientTable.NewRow();
                        newRow["Username"] = "johndoe";
                        newRow["CurrencyCode"] = "USD";
                        newRow["Email"] = "[email protected]";
                        newRow["Fax"] = "555-0101";
                        newRow["HomePhone"] = "555-0102";
                        newRow["MobilePhone"] = "555-0103";
                        newRow["FirstName"] = "John";
                        newRow["LastName"] = "Doe";
                        newRow["Language"] = "en";
                        newRow["Note"] = "New client";
                        newRow["Organization"] = "Example Corp";
                        newRow["State"] = "active";

                        clientTable.Rows.Add(newRow);

                        FreshBooksCommandBuilder commandBuilder = new FreshBooksCommandBuilder(adapter);
                        int rowsAffected = adapter.Update(clientTable);
                        Console.WriteLine($"Insert successful. Rows affected: {rowsAffected}");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred: " + ex.Message);
            }
        }
    }
}
PM> Install-Package Devart.Data.FreshBooks
using System;
using System.Data;
using System.Threading.Tasks;
using Devart.Data.FreshBooks;

namespace FreshBooksConsoleApp
{
    class Program
    {
        static async Task Main(string[] args)
        {
            string connectionString = "Authentication Type=OAuthInteractive;Company Name=Sapuk;";

            try
            {
                await InsertClientAsync(connectionString);
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred: " + ex.Message);
            }
        }

        static async Task InsertClientAsync(string connectionString)
        {
            using (FreshBooksConnection connection = new FreshBooksConnection(connectionString))
            {
                await connection.OpenAsync();
                Console.WriteLine("Connection successful.");

                string insertSql = @"INSERT INTO Client
                    (Username, CurrencyCode, Email, Fax, HomePhone, MobilePhone,
                     FirstName, LastName, Language, Note, Organization, State)
                    VALUES
                    (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

                using (FreshBooksCommand insertCommand = new FreshBooksCommand(insertSql, connection))
                {
                    insertCommand.Parameters.Add("Username", DbType.String).Value = "johndoe";
                    insertCommand.Parameters.Add("CurrencyCode", DbType.String).Value = "USD";
                    insertCommand.Parameters.Add("Email", DbType.String).Value = "[email protected]";
                    insertCommand.Parameters.Add("Fax", DbType.String).Value = "555-0101";
                    insertCommand.Parameters.Add("HomePhone", DbType.String).Value = "555-0102";
                    insertCommand.Parameters.Add("MobilePhone", DbType.String).Value = "555-0103";
                    insertCommand.Parameters.Add("FirstName", DbType.String).Value = "John";
                    insertCommand.Parameters.Add("LastName", DbType.String).Value = "Doe";
                    insertCommand.Parameters.Add("Language", DbType.String).Value = "en";
                    insertCommand.Parameters.Add("Note", DbType.String).Value = "New client";
                    insertCommand.Parameters.Add("Organization", DbType.String).Value = "Example Corp";
                    insertCommand.Parameters.Add("State", DbType.String).Value = "active";

                    int rowsAffected = await insertCommand.ExecuteNonQueryAsync();
                    Console.WriteLine($"Insert successful. Rows affected: {rowsAffected}");
                }
            }
        }
    }
}
PM> Install-Package Devart.Data.FreshBooks

Documentation

Licensing
Licensing
A detailed technical reference on embedding license information—a required resource for applications built with dotConnect for FreshBooks.
DataAdapter features
DataAdapter features
A guide to using the FreshBooksDataAdapter class for interacting with FreshBooks data in a disconnected architecture.
Parameters
Parameters
An overview of SQL query parameters and their synchronization, along with practical insights into working with stored procedures.
SQL translation
SQL translation
Since remote execution is significantly faster than client-side processing, using translatable SQL ensures optimal query performance.

dotConnect Universal

Get universal access to data from a variety of sources, including SQL Server, Oracle, PostgreSQL, MySQL, SQLite, DB2, InterBase, Microsoft Access, and Firebird. Other servers can be accessed through their ADO.NET, OLE DB and ODBC providers.

FAQ

What is the trial period for dotConnect for FreshBooks?
dotConnect for FreshBooks offers a fully functional 30-day trial. During this period, you can use and evaluate all features without limitations. After the trial ends, you can purchase a license to continue using the product.
Why do I need to install the product if NuGet is available?

dotConnect for FreshBooks provides two sets of assemblies, and the choice depends on your project type:

  • For .NET (.NET Core/.NET 5+) projects: Use the assemblies available via NuGet packages.
  • For .NET Framework projects: Use the Devart assemblies included with the product installer.
Where should I apply my License Key?

The method for applying your license depends on your project type:

  • For .NET (.NET Core/.NET 5+) projects, apply the License Key at runtime using the License Key connection string parameter.
  • For .NET Framework projects: no license key is needed. Simply download and install the licensed version of dotConnect from your Devart Customer Portal.
Do the end users of my application require a Devart license, or must I pay additional fees for deploying my software?

No, end users do not need a Devart license, and there are no additional deployment fees as long as you hold a valid Devart license.

According to the EULA, you're allowed to redistribute the following runtime assemblies with your application:

  • Devart.Data.FreshBooks.dll
  • Devart.Data.dll

You can include them in your app's folder (such as Bin for web apps) or register them in the GAC. Just make sure they are only used by your solution.

There's no need for a full installation on the target machine. Rather, you can use the "Minimal installation" option provided by the setup.

No other components of dotConnect may be distributed.

How can I update dotConnect to a new version?

To update dotConnect to a new version, you need to reinstall it:

  • Open Settings > Apps > Installed apps in Windows
  • Uninstall the current and any older versions of dotConnect, including Entity Developer and LinqConnect, if installed.
  • Visit the Customer Portal and download the latest licensed version.
  • Install the downloaded version and receive the latest features and improvements.
How can I completely remove all the previous versions of the product?

1. Go to Settings > Apps > Installed apps and uninstall:

  • All dotConnect providers
  • Entity Developer
  • LinqConnect

2. Manually delete any leftover files from the following locations (if they exist):

GAC folders:

  • C:\Windows\assembly\GAC_MSIL
  • C:\Windows\Microsoft.NET\assembly\GAC_MSIL

Program files and extensions:

  • C:\Program Files (x86)\Microsoft Visual Studio\...\Community\Common7\IDE\Extensions\Devart
  • C:\Program Files\Microsoft Visual Studio\...\Community\Common7\IDE\Extensions\Devart
  • C:\Program Files (x86)\Devart
  • C:\Program Files\Devart
  • C:\Program Files (x86)\Common Files\Devart
  • C:\Program Files\Common Files\Devart

Program data folders:

  • C:\ProgramData\Devart\dotConnect
  • C:\ProgramData\Devart\Entity Developer

Removing these ensures a clean system and prevents conflicts during future installations.

Wield the full firepower of dotConnect for Freshbooks
Go with the advanced edition of dotConnect for Freshbooks and stay at the top of your game from day one!