Submitting LFQL Queries
The basic procedure for submitting LFQL queries is as follows:
- Sign in to the repository.
- Create a new
LfConnectionobject using your current session. - Use the
LfConnectionobject to create anLfCommandobject. - Specify the
LfCommandobject’s command text in the LFQL query language. - Use
LfDataReaderto execute the command and obtain the results.
The following sample retrieves a list of entries that have been assigned the “Receipt” template, returning their names and IDs.
using (Session mySession = new Session())
{
RepositoryRegistration myRepoReg = new RepositoryRegistration("myLFServer", "myRepo");
mySession.LogIn("myUsername", "myPassword", myRepoReg);
LfConnection conn = new LfConnection(mySession);
conn.Open();
LfCommand lfqlCommand = conn.CreateCommand();
lfqlCommand.CommandText = "SELECT entry_name, entry_id FROM lf.entry WHERE pset_name = 'Receipt'";
Laserfiche.RepositoryAccess.Data.LfDataReader reader = lfqlCommand.ExecuteReader();
if (reader.HasRows) // check for non-zero result set
{
while (reader.Read())
{
System.Windows.Forms.MessageBox.Show("Entry Name: " + reader["entry_name"].ToString() +
" | Entry ID: " + reader["entry_id"].ToString());
}
}
}