in

CodeSmith Community

Your Code. Your Way. Faster!

External

April 2008 - Posts

  • Getting Started with CodeSmith - Hello World!

    CodeSmith is really a cool tool and experience programmers should make it part of their arsenal.  Not only can CodeSmith automate many of the redundant coding task a team does, but the templates that comes with it is great for studying a lot of the industry patterns available including nHibernate, NetTiers and CSLA. So, what is CodeSmith? CodeSmith is a template based code generator.  In concept it is very similar to .NET ASPX pages, except that ASPX generates HTML but CodeSmith generates a
  • EntitySpaces Beta II - Full CodeSmith Support (C#/VB)

    kick it on DotNetKicks.com

    imageThe EntitySpaces 2008 Beta II is now available. The version number is 2008.0.0427.0 and is available for download now on our home page. You should uninstall any prior ES2008 alpha or beta that you may have installed. You can run ES2007 and ES2008 side-by-side. Do not install ES2008 over the top of ES2007. EntitySpaces 2008 has proven to be a big undertaking. Every EntitySpaces template has been rewritten using our new metadata engine and is now supported in both MyGeneration and CodeSmith, many were converted from VBScript to C#. However, from this point forward we start knocking off issues on our roadmap in rapid fire fashion. We are a little behind on our May 15th release date, but not too far. Not only is the trial available for download but both the Developer version and Source version are available to customers as well.

    The testing behind this release is tremendous. We have two code generators in play, C# and VB.NET templates, and to top it off we had to debug Oracle subquery issues with messages like "ORA-923 No worky, try again" (kidding, but only slightly). Throw in database independence, the Compact Framework, and you really have your hands full. However, we are over the hump now and can see the light. This is a little off topic but we cannot wait to put up our Silverlight demo showing EntitySpaces working hand-in-hand with Silverlight. Our Silverlight demo is being worked on by Jon Davis and when we saw his first cut we were very impressed, Jon is a very sharp guy indeed.

    We've made some good changes too with our installs. Both our Trial and Developer versions install exactly in the same folder structures. This will avoid confusion for those folks who use the EntitySpaces Trial for a large part of their development process and then purchase the Developer version before going live. Now you can simply install the developer version right over the top of the trial and not worry about changing reference paths. This beta comes with all providers, including our Compact Framework providers, it also comes with a SQL CE desktop provider in addition to the Compact Framework version. The beta will automatically install into both MyGeneration 1.2 and 1.3 folders and add support for CodeSmith. See the Getting Started documents on your menu after installation. There is a "Getting Started.PDF" for both MyGeneration and CodeSmith. Just a quick note for our MyGeneration customers. If you have any user meta data defined for aliases or Oracle or PostgreSQL sequences be sure to run the UserData template. It will convert the MyGeneration user data file to our new format upon first run. From that point on you maintain your user meta data via our UserData template and not through MyGeneration.

    image

    You can see by the image on the right that the runtimes are easily found in the Runtimes folder. We have both .NET 2.0 and 3.5 assemblies as well as Compact Framework assemblies (we now use CF and not Ce for those in our naming convention). Also notice that the CodeSmith templates are under the EntitySpaces 2008 folder. The "Getting Started.PDF" for CodeSmith will show you how to setup a Template Folder Shortcut in CodeSmith, it's a snap.

    Our ES2007 EntitySpaces demo still hasn't been converted thus our ES2008 demo is very lightweight. We are going to rewrite it and not just convert it so that's the reason why we've held off. There could be some minor breaking changes coming when we tackle a few things on the roadmap, however that's not the usual case for EntitySpaces. We do want to address a few things to make your lives easier though.

    We really hope a lot of our users start taking a serious look at ES2008, our Subquery and Casting support is very powerful and we will have a ton of enhancements rolling out soon as we head for the official release. We have also prototyped LINQ to SQL with EntitySpaces. And even more exciting when talking to Jon Davis about Silverlight we spoke about adding the very popular EntitySpaces DynamicQuery API to our proxies as an option. You could then issue full ES2008 dynamic queries from within Silverlight (down in the client) and from other situations such as WCF conversations where you might not have EntitySpaces on the client. All of this is to say that when we release EntitySpaces 2008 that is not the end, but the beginning.

    We are very excited about where we are going and have a great vision for EntitySpaces. Not only can we run on Mono, Medium Trust, the Compact Framework, but we can provide seamless support for Silverlight as well. Mike Griffin will be demonstrating a lot of these high end features at the Indy ALT.NET meeting on May 15th.

    So download the ES2008 Trial and if you hit a snag please post on the forums and we'll get you a speedy response.

     

    EntitySpaces

    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, a Mono application, 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 LLC
    Persistence Layer and Business Objects for Microsoft .NET
    http://www.entityspaces.net

  • Senior C#.NET Developer / Architect With Codesmith

    Senior C#.NET Developer / Architect With Codesmith Experience Contract Senior C#.NET Developer/Architect with Codesmith experience Looking for a strong C#.NET Developer who has experience utilizing Codesmith for code generation and who also has experience utilizing ASP.NET and SQL Server 2005. The c ...

  • Sr. C#.NET Developer/Architect with Codesmith experience

    GA-Atlanta, Looking for a strong C#.NET Developer who has experience utilizing Codesmith for code generation and who also has experience utilizing ASP.NET and SQL Server 2005. The consultant will be developing hi
  • Using Codesmith and .netTiers to build a Data Access Layer

    Some time ago, I have involved in a National Energy company information system (CIS) development. It is actually the project developed by my company and I am a junior of the developer team. We start it by explaining and discussing about all the detail and requirement of database because this is the main part and most important part of this project. My data layer syntax in asp.net is using codesmith and .nettiers as tools to simplified and shortened my programming.

    Main

    Codesmith is a client application that uses templates to generate code. It saves time. It reduces repetitive coding. .NetTiers is an open source tools that provides templates for codesmith to generate a n-tiered architecture. Combine these 2 client applications can quickly create the datalayer for the project. It does simply provide a Business Object like Employees, Companies, and others. This is done by creating collections. You can insert, update, select from databases in a different way besides ado.net method as usual. Maybe you can view the details of what these two are from their sites.

    If you want to try, first you need to download codesmith and .nettiers and then install them, mine is using codesmith 4.0. Then open codesmith explorer. Click open folder from top corner of codesmith explorer then browse to your nettiers installation folder. After that execute Nettier.cst as shown below. 





    So there are minimum three attribute now you must config in the next opened window. It is select database source you want to use in the project development. In this case mine is CISdata which have been designed before using Power Designer 11. Second set the output directory. And third is set the namespace. Namespace is used for your database collection access later. For example my namespace is CISLib. Later I can write Imports CISLib, Imports CISLib.DAL, Imports CISLib.DAL.DataRepository, Imports CISLib.DAL.SqlClient in my asp.net vb coding. Last click generate. 






    Now we can wait for quite some time depends on your computer specification. It takes about 1-2 minutes to complete. If all goes well, you’ll have a new solution in the folder you selected as output directory. Open the solution. You’ll see that it has three projects. All three set to produce DLLs. Next most important step is to copy all .DLL files you generated from the output bin directory to your project bin directory. 





    Last thing is to config Enterprise Library Configuration from nettiers. Navigate to Start Menu, nettiers, Enterprise Library Configuration. Minimize it. Open Your visual studio solution. Add another project to the solution. Add a new item to the project. Select Application Configuration File as the type. It’s called App.conf by default. Leave it as it is. Open Enterprise Library Configuration window. Click on Open File and select the App.Conf you just created.

    Three important part to config is nettiers application block, SQL data provider instance, SQL connection string->database, integrated security, and server. After all save it. This generates some *.conf files in your project directory. Go there and copy all of the *.conf files to your bin directory. This is the end of codesmith and nettiers installation and configuration part. Next step is how to use it. 

     


    I’ll include part of my asp.net vb coding to let us understand how to use this as a collection to connect to the database which we already generated before. 

    Imported library.

     

    The method to insert to the database.

    Key syntax here are 'Dim objCompany as New COMPANIES'. Table COMPANIES in database now can be inserted with values from input textbox on asp.net form with easier method, example insert value to COMPANY_ID, STATUS_ID filed in COMPANIES table is just as simple as shown below, instead of declare connection, command, and executenonquery as usual.

     

    The method to select/retrieve data from the database.

    Key Syntax is also in declaration of COMPANIESCollection object. We can notice here object declare as COMPANIESCollection for database retrieve instead of only as COMPANIES for database insert. One more important syntax is COMPANIESProvider.getpaged. It is the syntax used in codesmith and nettiers implementation. There are a lot more of syntax we can use for this data layer connection. For more expertise explanation about it, maybe we can look from their original help and tutorial.

    Region "Company"

        Private Sub showCompanyData()

            Dim objCompanyCol As New COMPANIESCollection

            Try

                objCompanyCol = COMPANIESProvider.GetPaged("COMPANY_ID='2'", "", 0, 999, 999)

     

                If objCompanyCol.Count > 0 Then

                    txtCompanyID.Text = objCompanyCol(0).COMPANY_ID

                End If

            Catch ex As Exception

                Response.Write(ex.ToString())

            End Try

        End Sub

     

        Private Sub getCompanyIDMaxnum()

            Dim objCompanyCol As New COMPANIESCollection

            Try

                objCompanyCol = COMPANIESProvider.GetPaged("", "CAST(COMPANY_ID AS INT) DESC", 0, 999, 999)

     

                If objCompanyCol.Count > 0 Then

                    txtCompanyID.Text = CStr(CInt(objCompanyCol(0).COMPANY_ID) + 1)

                Else

                    txtCompanyID.Text = "1"

                End If

            Catch ex As Exception

                Response.Write(ex.Message)

            End Try

        End Sub

    #End Region



    Conclusion

    The possibilities for CodeSmith templates are limited only by your own creativity. As I've demonstrated in this article, CodeSmith is an exceptionally powerful developer productivity tool. Coupled with the .NetTiers templates you can write a best practices Data Access Layer for your application in a matter of minutes.

    References

    All the useful links or references that can help you learn about this tutorial

    1. http://www.codesmithtools.com/
    2. http://www.nettier.com

  • In Eager Anticipation of New England Code Camp 9

    I've been spending my latenight geek sessions this week preparing for my "Patterns of Splendor" Advanced CodeSmith presentation at New England Code Camp 9 this weekend.  That means updating Visual Studio projects, databases and CodeSmith template libraries on my laptop and walking through the demos to make sure there are no glitches.  The fact that CodeSmith with version 4.0 saves all template properties from the prior execution will keep the Splendid Show moving along breezily.  There's a lot to show.  I don't want to get caught up in CodeSmith or Community Server details but be true to the objective of the talk, which is to demonstrate how CodeSmith can generate volumes of code regardless of the application's architecture when we approach those applications as replicable patterns of code.

    Here's the full weekend presentation schedule. The first thing I always look for is if Richard Hale Shaw will be there.  Indeed Richard is on the Code Camp 9 slate, with not two sessions, but THREE, "Best Practices in ASP.NET 2.0/3.5: Defending Yourself From Worst Practices", "Functional ReFactoring: Adding Clarity and Grace to Your Code" and "LINQ isn't just for Breakfast, anymore: Applying LINQ and Strategies for Migrating to It."  Patrick Hynds will be back after missing the last two Code Camps as well.  Woot!

    The best news for Code Camp 9, of course, is that our own Jason "Interesting Find" Haley is flying in from Seattle to say hello to his old Beantown homies and deliver a couple of super nerdy presentations that as usual I will certainly not be able to understand.  Jason always packs the room, so I know a lot of guys smarter than me will understand what he's talking about.

    I should be getting into Waltham around 7:30 on Friday night and plan on ordering my dinner aperitif at the Naked Fish at 8:00 sharp.  If you want to join me (and a special guest from Maine--who's been jerking me around with empty promises of fresh Code Camp Lobster for several Internet years), please let me know!  You are most welcome.

    Don't forget about our Saturday Night Geek Fest in the Waltham Westin Lobby.  I'll do my best to be the DPG (Designated Party Goofball), but I might be a bit distracted this time around as my beloved Tarheels will be playing Kansas on the Big Screen.

    Nothing left to say.  New England Code Camp is dreamy.  Chris Bowen is even dreamier (in a totally manly, non-sexual way, of course.)  It's going to be great!

Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems