Skip to content

Getting Started

bbsimonbb edited this page Feb 27, 2020 · 7 revisions

QueryFirst is a visual studio extension for all Visual Studio versions and editions starting Visual Studio 2013. Install it from within VS, searching for QueryFirst.

To Use QueryFirst in a project you will need to create a qfconfig.json file and a QfRuntimeConnection class. Minimal versions of these are as follows...

qfconfig.json, put it where you like, next to or above your .sql files.

{
  "defaultConnection": "Data Source=localhost;Initial Catalog=Northwind;Integrated Security=True"
} 

QfRuntimeConnection. Add this class to the namespace you'll use for your queries.

using System.Data;
using System.Data.SqlClient;

namespace MyProject
{
    public class QfRuntimeConnection
    {
        public static IDbConnection GetConnection()
        {
            return new SqlConnection("Data Source=localhost;Initial Catalog=Northwind;Integrated Security=True");
        }
    }
}

Create a query

QueryFirst queries live in .sql files, created with the QueryFirst template that you should now see under Add => New items => Visual C#.

Once in the template, your query goes after the -- endDesignTime flag.

QueryFirst template

Clone this wiki locally