When I first started using LINQ to VFP I didn’t mind manually writing Entity classes and mapping the data but after awhile I found it to become a tedious task. So I decided to write a code generation application that would work with LINQ to VFP and the IQToolkit SQL Server Provider. This application has really turned out to be a play thing for me so that I can get some hands on learning with WPF and Spark View Engine. But before I’d allow myself to get to far into playing around I wanted to make sure I got the core functionality done. At this point I have an alpha build available for anyone interested.
As expected, you can use a full connection string to access VFP or SQL Server. There are also a few unconventional connection options. You can specify the full path to a dbc file or a specify a directory for free tables. Both of these options will be used to create a connection string for VFP. You can also provide a modified version of a SQL Server connection string that includes a pipe delimited list of databases (Example: Data Source=.;Initial Catalog=Northwind|AspNet;Integrated Security=True).
The Data Context Settings allow you to specify the class name, output file, and namespace for both types of these Data Contexts. The Base Class setting is for the Repository Data Context.
By default, the Entity Provider Template was designed to work with the Attribute Mapping Template and the Repository Provider Template was designed to work with the Xml Mapping Template.
Enter all the setting values and then click the Load Data button. Then the grids will be populated with the Tables, Columns, and Associations information.
The Tables grid is pretty simple to use. Just check the checkbox in the Include column if you want an Entity class created. The Entity class name can be specified using the grid’s Entity Name column.
The Columns grid shows the Columns of the selected row in the Tables grid. This grid has a few more available options than the Table grid but is just as easy to use. Check the checkbox in the Include column if you want the Entity class to include the property for the selected column. In this grid, you can also change the name and type of the property as well as identify the primary key and indicate if it is an auto generated key.
The last grid shows the Associations. This grid has an Include column and a Property Name column that can be set.
Click the Generate Files button after all the mapping information has been entered to complete the process.
Don’t like my templates?
The template files are distributed with this application so feel free to modify the templates as needed. Additionally, if you feel that you need to add a new template just add it to the appropriate folder and it will show up in the combo box after resetting the application.
This is a diagram shows the Template classes along with classes that they reference.