How to Generate and Work with DA LINQ Table Definitions
(This page is considered "good" on a technical level, but is pending review for grammar and typos)
One of the key elements in accessing data via DA LINQ are table definition classes (also called DA LINQ Classes). These classes map the Server Schema to a set of .NET classes, thus allowing strongly-typed LINQ-based access to database.
The article below describes how to regenerate DA LINQ Classes when a server's Schema is changed. Also this article explains several ways to invoke the table definition generator (or DA LINQ Wizard as it is called in the article below).
In the simplest case the solution contains a custom Data Abstract server and with it one or more actual .daSchema files. In this case, it is possible to right-click the .daSchema file and choose the Create DA LINQ Table Definitions item from the context menu:
This will launch a DA LINQ Wizard for this process, in this case with only a single page:
This screen allows to specify three things:
- The file to generate or update. If there’s already one (or more) existing table definition source files in the current solution, an existing file can be selected (from any of the solution's projects); also a new file to be created can be specified.
- The namespace to be used for the generated or updated file.
- The list of tables to generate classes for.
The DA LINQ Wizard will automatically persist the existing namespace, as well as any tables previously decided to not generate code for by unchecking them (new tables that have been added to the schema since last table definition regeneration will be checked by default).
After the Finish button is pressed the code file with DA LINQ classes will be created (or updated) and opened in the IDE.
.daRemoteSchema files store remote server connection settings (however they do not store user passwords or server AES password, if any). The Project Wizard (or the DA LINQ Wizard) will automatically add these files to the client project as needed.
As with a .daSchema files, it is possible to right-click the .daRemoteServer file and choose the Create DA LINQ Table Definitions item from the context menu. When invoked, it opens the same DA LINQ Wizard as for the .daSchema file, but with an additional first step:
The DA LINQ Wizard gathers the location and connection options for the remote server from the .daRemoteSchema file and allows to adjust them if necessary. After the Next button is pressed, the DA LINQ Wizard fetches the schema from the server (which should be running and accessible), and then continues on to the same page as for the .daSchema file.
Note: The .daRemoteServer file doesn't store any login information and/or server's AES password, so it can be safely added to a version control. Credentials are encrypted and stored in a separate .daRemoteSchema.user file for future reference, so it is not needed to re-enter login data every time the DA LINQ Wizard is invoked.
.relativityClient files serve the same purpose as the .daRemoteSchema files except they provide reference to a Relativity Server, not a custom Data Abstract-based servers.
Once again, the Project Wizard (or the DA LINQ Wizard) will automatically add these files to the client project as needed.
It is possible to right-click the .daRemoteServer file and choose the Create DA LINQ Table Definitions item from the context menu. As above, selecting this option shows the DA LINQ Wizard, this time with a page tailored for the Relativity Server connection:
This page allows to verify or update the server address (the DA LINQ Wizard and .relativityClient files also support ZeroConf-discovered servers), and select a Domain and Schema to work with. All these settings will be persisted in the .relativityClient file for future reference. After the Next button is pressed, the DA LINQ Wizard fetches the schema from the server (which should be running and accessible), and then continues on to the same page as for the .daSchema file.
Adding new client connectivity
In addition to invoking the DA LINQ Wizard from the three file types seen here, it can be also triggered from a Data Adapter's context menu, global menu item (RemObjects SDK|Create DA LINQ Table Definitions) or a button in the Solution Explorer toolbar.
When invoked in this fashion, the DA LINQ Wizard will allow to select the possible connection type:
- Proceed with an existing .daSchema, .daRemoteSchema or .relatvityClient file, if one exists in current solution (this will take the exact same path as if invoked straight from the file as seen above).
- Connect to an existing Relativity Server domain.
- Freshly connect to an existing remote Data Abstract server.
The last two options will ask for the connection parameters for the server to connect to (using Wizard pages similar to the ones seen above), and then automatically add a new .daRemoteSchema or .relativityClient file to the project, alongside the generated code file.
Note: The DA LINQ Wizard doesn't add any references to RemObjects Data Abstract assemblies to the client project while generating the DA LINQ classes. The references to RemObjects assemblies should be added manually, if needed.
New DA LINQ Wizard streamlines the table definition generator interface and allows to store the server connection parameters.