In mid March we are going to offer an Alpha release of EntitySpaces 2008 (ES2008) for CodeSmith users. If you are a MyGeneration fan don't worry, your support will be in the Beta release of ES2008 the date of which hasn't been announced yet. This is an image heavy post and we apologize for that, it was really the best way to demonstrate our CodeSmith support. For those interested in code generation if you follow along you will see just how easy our new code generation syntax is.
This post will serve to introduce to you our new EntitySpaces esMetadataEngine which is a pure C# assembly that doesn't rely on COM interop. The esMetadataEngine combines some of the best features of the MyMeta engine from MyGeneration and also combines the esPlugIn assembly and the Dnp.Utils assembly all into a single assembly which is installed in the GAC. Our esMetadataEngine supports Microsoft SQL Server and SQL Server CE, Oracle, MySQL, PostgreSQL, VistaDB, and Microsoft Access. Other database engines will be added as we add support for them. The esMetadataEngine works equally well under both CodeSmith and MyGeneration. For those wishing to extend and customize EntitySpaces we think you are really going to like the EntitySpaces esMetadataEngine.
In the CodeSmith Template Explorer (shown above) we use the right mouse button to execute our "Generated Classes Master (C#)" template. Take a look at the user interface shown below.
Because we use our own metadata engine and not the CodeSmith Schema Explorer we need to provide our own connection information. However, we make this very easy. Notice the little " ... " button above on the "CLICK HERE FOR EASY SETUP" property. When you click on that button you will be presented with the dialog shown below.
In our setup dialog above you can connect to your database and choose any number of tables (multiple selection) or views for which to generate EntitySpaces classes. Once you press the "Ok" button we work some "magic" and all of the appropriate properties in the CodeSmith property dialog are auto-filled with your selections.
In the image above you can see how the ConnectionString, Database, and Entities have now been populated. If you click on the Entities property you will see that it is a normal CodeSmith StringCollection and will be presented as follows (shown below) if you were drill into that property.
Again, our easy "SetupDialog" makes all this setup painless and supports multiple selection for your tables and views. You can generate your entire EntitySpaces 2008 Architecture in a single template run. We play well and fully support CodeSmith projects as well.
So let's take a look at how the esMetadataEngine makes life very simple. Take a look at our Master template shown below.
First we register and import our esMetadataEngine assembly followed by the registration of our subtemplates (which you can see in the first image in this post). Next, we declare our user interface properties. This is all pretty straightforward for the average CodeSmith developer.
The image above shows how we create an instance of the esMetadataEngine and connect it to the database using the UI properties from the CodeSmith property grid. Next, we add all of the user interface variables to a Hashtable built into the esMetadataEngine for just such a purpose (the sub templates will grab their values from here). Remember, we want our templates to be 98% the same for both CodeSmith and MyGeneration (and they are).
The above image shows how we instantiate all of our subtemplates being sure to hand them a reference to the esMetadataEngine.
The master template simply loops through a list of entities (tables or views) chosen by the user and invokes each subtemplate within a foreach loop asking it to RenderToString() its content. That's pretty much our entire master template. You'll be even more impressed at how simple our subtemplates look (and are to to create).
Now, let's take a quick look at one of the subtemplates.
The above image shows an entire subtemplate. Notice that there is no looping. The master template does the looping and calls the subtemplate for each table or view selected by the user. A subtemplate will extract the UI variables it needs from the esMetadataEngine.Input Hashtable. Notice also the syntax "esMeta.esPlugIn", this shows our ES2007 esPlugIn has been built right into the esMetadataEngine. Finally, at the bottom you can see the "TheMetaData" property that the master template uses to pass itself to the subtemplate. Granted the above template is a very simple subtemplate but it should give you an idea of how this all works. I loved the full intellisense and easy debugging built into CodeSmith as well.
What is important is that other than the few tags at the very top there is no native CodeSmith API calls in any of our subtemplates. The master templates account for the 2% difference we will have between our CodeSmith and MyGeneration support. Basically, the master templates deal with the unique UI techniques and subtemplate execution methodologies between CodeSmith and MyGeneration (which is very easy to handle). The subtemplates are nearly and entire wholesale copy paste between code generation engines. Now, if you're looking forward to customizing and extending EntitySpaces and even sharing templates with others this is how you want to do it, and you can reach out to both CodeSmith and MyGeneration users. This isn't the whole story however, still much to come concerning customizing and extending.
However, code generation enhancements are not all we are doing. In our team meeting tonight I was shown our SubQuery unit test fixture an almost flipped. In about a week we are going to do an amazing blog post on SubQueries that promises to really WOW you.
From mobile devices to large scale enterprise solutions in need of serious transaction support, EntitySpaces can meet your needs. Whether you’re writing an ASP.NET application with medium trust requirements, or a Windows.Forms application, the EntitySpaces architecture is there for you. EntitySpaces is provider independent, which means that you can run the same binary code against any of the supported databases. EntitySpaces is available in both C# and VB.NET. EntitySpaces uses no reflection, no XML files, and sports a tiny foot print of less than 200k. Pound for pound, EntitySpaces is one tough, dependable .NET architecture.
The EntitySpaces Team--
EntitySpaces LLCPersistence Layer and Business Objects for Microsoft .NEThttp://www.entityspaces.net
Page rendered at Tuesday, March 16, 2010 5:08:56 PM (Eastern Standard Time, UTC-05:00)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.