# Thursday, January 07, 2010

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. 

image


Settings Overview:

image
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). 

image
The Data Context Settings were designed with two different Data Contexts types in mind.  The first Data Context is an Entity Provider which is basically a class that has a property for each Entity.  This type of Data Context is what the IQToolkit Tests use.  The other type of Data Context is a based on a Repository Pattern which uses Generic methods instead of accessing an Entity property. 

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.

image
The Entity Settings allow you to specify the file extension, namespace, output path, and template.  There is only one Entity template available. 

image
The Mapping Settings can be used to create an Attribute Mapping class or an Xml Mapping file.


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.

Getting Started:

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.

image

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.

image

The last grid shows the Associations.  This grid has an Include column and a Property Name column that can be set.

image

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.

image

1/7/2010 6:55 PM Eastern Standard Time  #    Disclaimer  |  Comments [3]  | 
Wednesday, March 10, 2010 3:54:42 PM (Eastern Standard Time, UTC-05:00)
I gave your IQToolkit CodeGen a try. At first I had trouble that it couldn't find a provider for vfp, managed to work around it. So now I have a feature request. The VFP dB that I have to work with has a lot of tables & columns. It's so big it took about 10+ minutes just to Load the Data How about a way to select/unselect all for "Include" for each DataGrid.


Thanks
Mitch
Mitch
Friday, March 19, 2010 6:08:09 PM (Eastern Standard Time, UTC-05:00)
Thanks for the feedback Mitch. I added a select/unselect checkbox to the application some time ago. But it seems my download link targeted a specific version posted on codeplex. I changed the link to point the download page (http://iqtoolkitcontrib.codeplex.com/releases).

Is there any chance that I could get your data structure to investigate why the application takes so long to load?
Tom Brothers
Thursday, July 15, 2010 3:56:54 AM (Eastern Daylight Time, UTC-04:00)
Hi,

We got Sql ServerDB and VFP DB . I used your tool to generate entity class. If I put VFP connection string in your tool , it generats properties for each column in VFP table. If I put SQL Server connection string in your tool , it does not generate the properties for numeric column in Sql Server table.

I need entity class which I need to use with both Sql server provider and VFP provider, which are based on IQtoolkit. So I need consistent entity class. We have consisten datastructure in both SQl DB and VFP DB.

kind regards,
Nandita Reshamwala
Nandita Reshamwala
All comments require the approval of the site owner before being displayed.
Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview