Rapid C# Windows DEVELOPMENT Visual Studio 2005, SQL Server 2005 & LLBLGen Pro Rapid C# Windows DEVELOPMENT Visual Studio 2005, SQL Server 2005, & LLBLGen Pro Quickly Build Robust, Database-Driven Applications Joseph Chancellor © Joseph Chancellor 2006 Rapid C# Windows DEVELOPMENT Visual Studio 2005, SQL Server 2005, & LLBLGen Pro © Joseph Chancellor 2006 All rights reserved No part of this book may be reproduced, stored in a database of any kind, or transmitted in any way, form, or means without consent of the author, except for brief quotations for reviews or articles The information in this book is provided without any express or implied warranty The author, publisher, and any distributor are not responsible for any damages or loss arising directly or indirectly from the use of this book First Edition February 2006 Published by Lulu.com Cover Photo: QiangBa DanZhen iStockPhoto.com Photographer http://www.photosource.com/2650 Back Photo: Elena Slastnova iStockPhoto.com Photographer http://hiero.ru/Yougen Cover and Book Design: Joseph Chancellor Visual Studio NET 2005, SQL Server 2005, ClickOnce, Visual C#, and IntelliSense are trademarks of the Microsoft Corporation LLBLGen and LLBLGen Pro are trademarks of Solutions Design Table of Contents 1: Introduction .1 Commanding the Army Prerequisites O/R Mappers Strongly-Typed Objects Native Language Filter Construction Strongly-Typed DataSets vs LLBLGen Pro N-Tier Application Design 11 Stored Procedures, Inline, and Dynamic SQL 11 Data Type Conversion 14 Visual Studio Advantages 14 Summary 14 2: The O/R Mapper 17 Preparing the database 17 Our schema AdventureWorks 18 LLBLGen Pro Objects .18 Scanning the Schema 19 Creating Entities 21 Entity Options 22 Adding Views 26 Creating Typed Lists 28 Adding Stored Procedures 30 Self Servicing vs Adapter .31 One Class vs Two Classes 32 Generating the Code .34 3: Solution Setup 37 Creating the solution .37 Adding references 39 App.config settings 40 LLBLGen Pro Project Overview 41 4: MDI Parent Form 43 MDI Parent .43 5: Simple Forms 49 Calling a Stored Procedure 49 Alternative Approach Using Entities and Relationships 54 Using Typed Views 58 Using Views as Entities 63 Using Typed Lists 64 Summary 64 6: Search Form 65 Order Search Form 65 7: Edit Form .75 Entity Extensions 75 Form Layout 76 Saving Entity Data 81 Creating New Entities 82 Deleting an Entity 83 8: Validation 85 Field Validation 85 Entity Validation .91 9: Transactions 95 Preparing for the Unexpected .95 Isolation Levels 97 10:Tuning 101 Enhancing Performance .101 SQL Server Profiler 101 LLBLGen Pro Tracing 105 Simple Prefetching 106 Complex Prefetching 107 Multi-threading 108 Code Cleaning .112 11:Deployment 115 Measure Twice, ClickOnce 115 Certificates 116 Strong Name Key 117 ClickOnce Configuration .117 Deployment 121 Installation 121 12:Regenerating Code 123 Inevitable Changes 123 Minor Changes 123 Major Changes 129 13:Appendix 133 14:Afterword 135 Introduction Introduction “A good plan, violently executed now, is better than a perfect plan next week.” George S Patton (1885 – 1945) “Never put off until run time what can be done at compile time.” David Gries, Compiler Construction for Digital Computers Commanding the Army After a long and bloody fight for the territory of ancient China, Liu Bang finally prevailed over his rivals Born from a peasant family, Bang became the first emperor of the Han Dynasty Known as a bold and arrogant man, he discussed his recent military successes with his finest general “How many soldiers could a person like myself command?” the Emperor asked confidently “Your Majesty could command but 100,000 men” the general stated matter-of-factly “Then how about you?” the Emperor asked “In my case,” the general replied, “the more, the better.” The Emperor laughed with surprise “If that is so, then why are you my subject?” the Emperor asked “Your Majesty’s talent lies not in the commanding of troops,” the wise general replied “Your Majesty’s talent lies in the commanding of generals.” As a software developer, you also command a vast army of systems and architecture with almost limitless possibilities But unfortunately for the developer, the technologies change almost hourly Unlike the armies of yesterday, the codewarrior of today is likely to find his or her weapons obsolete and battle plans insufficient to face new challenges that did not even exist last week The concept for this book arose from a set of new programming tools and techniques that are not yet widely adopted in the developer community Much of the reason for this oversight is a lack of understanding, and it is the aim of this book to help correct that deficiency These tools are very similar to the Chinese general in the Han Dynasty: they are ruthlessly effective at what they do, and with them you can literally save hours, days, and weeks of development time and code maintenance Do not make the mistake of becoming a micro-managing Emperor: you not need to it all yourself You are not trying to directly command the most troops (or personally write the most lines of code) You are trying to win the war! And you are about to take a major step forward Through the exercises in this workbook, you will learn how to use C# with Visual Studio NET 2005, SQL Server 2005, and an invaluable tool called an O/R Mapper (in this case, LLBLGen Pro) to rapidly develop database-driven applications You will gain an understanding of the benefits of using these technologies and you will see the complete process from start to finish, including scanning the database schema, generating code, adding business logic, and building the user interface We will also cover validation, transactions, performance tuning, multi-threading, and deployment While there are books, websites, and documentation that cover all of these technologies individually, we will aim in this book to demonstrate how they can be used together as a rapid and robust solution, giving the developer a practical walk-through with a multitude of explanations, diagrams, and screenshots There are countless other methods and languages that a programmer could use to meet his or her database application needs However, the methods in this book are expedient and have been proven to work Judge for yourself as we walk through building a Windows application together Chapter Who is this book for? • • • • • • • Beginners who have some experience programming in C# and are familiar with basic programming terminology Intermediate developers who want to learn new techniques to shorten their development time Technology strategists who are investigating this approach in order to choose a platform for a project Those who want to put together a quick-and-dirty proof of concept for a database-driven application Those who have some familiarity with SQL programming (You not need to be an expert, but you need a basic understanding of the SQL syntax to use and understand the generated framework.) Those wishing to learn cutting edge development skills and techniques Small development teams Using these methods, even a single developer can make a powerful database-driven application and deploy it to their organization in a short amount of time No large budget or department of developers required Who isn’t this book for? • • • • Non-Windows developers Developers who are completely unfamiliar with object-oriented programming We are not going to explain all the details of OOP and you may not understand the concepts or code if object-oriented programming is completely new to you Developers with no SQL programming experience While LLBLGen Pro will help you compensate for weakness in SQL, you may have a difficult time understanding and using the framework to write queries if you have no understanding of SQL syntax Fundamentally, LLBLGen Pro is a wrapper (and more) for SQL, and knowing the basics will ensure that you can take full advantage of the tools Those who are so familiar with SQL that they think in stored procedures and refuse to learn new techniques You will want to avoid the temptation to just write a stored procedure instead of figuring out a way to use the generated framework Like anything else, learning these new techniques takes time Be patient, and you will achieve the results you want How to read this book This book is a practical walk-through that will build a sample application—step-by-step—with directions, screenshots, and code samples The book is intended to provide all the information necessary for a beginner to fully learn and grasp the tools In order to gain maximum benefit, be sure to follow along with the sample application, performing the directions on your machine as explained in the text However, if you are an intermediate user more familiar with the underlying concepts, you may elect to simply read the chapters and examine the code samples until you understand what is presented Optionally, you can create your own project while reading through the book, using the concepts presented, and making substitutions where necessary to apply it to your database schema and make it fit your application requirements Prerequisites In order to fully utilize this book, you will need: Visual Studio NET 2005 (highly recommended) Currently in full release as of November 2005, you can buy this software from Microsoft at http://msdn.microsoft.com/howtobuy Visual Studio NET 2005 has a variety of versions and prices Look for a version that includes C# and that allows you to develop class libraries and Windows applications (You can use older versions of Visual Studio, but you will miss some of the newer, time-saving features Refer to Figure 1.1 for a detailed Introduction Figure 1.1 Visual Studio NET 2005 version and feature comparison Source: http://msdn.microsoft.com/vstudio/products/compare/ *This book focuses on Windows forms although many of the techniques presented are also transferable to web forms comparison of the versions of Visual Studio NET 2005 available and the versions which include the features necessary to take full advantage of this book.) SQL Server 2005 (or other compatible database required) In this book we will be building database-driven applications with SQL Server 2005 Microsoft offers a variety of SQL Server products—including a limited version that is available for free—and developer versions that accompany specific versions of Visual Studio NET 2005 Please note that we will not be covering the creation of your database or designing your schema We are assuming that you have already developed your database or already have a database available Instead of SQL Server 2000/2005, you can also use previous versions of SQL Server, Microsoft Access, Firebird, Oracle, or MySQL, and for the most part, the process will be the same Note, however, that SQL Server 2005 was used exclusively in the creation of this book Therefore, if you use other database applications, your results may vary LLBLGen Pro (required)1 Version: 1.0.2005.1 LLBLGen Pro is an O/R mapper This tool will take an existing database schema and generate a data access tier (and more!) in a matter of seconds LLBLGen Pro is available from http://www.LLBLGen.com for about $270 USD (EUR 229) and can be used by your entire development team Although the product is an extra item to purchase, it is an invaluable tool for developers working with databases (a fully-functional 30 day demonstration version is also available and will allow you to work through the exercises in this book) Keep in mind that there is a free version of LLBLGen available, but we will not be using it because it uses stored procedures exclusively and only does a fraction of what the current version will The original version was entirely reengineered, rewritten, and released as 1) Please note that the products discussed in this book are recommended on their merit alone; the author is not employed by Solutions Design (the creators of LLBLGen Pro) or any other software company, and does not receive any kind of commission or compensation from any of these companies Chapter Figure 1.2 Lines of code generated/automated versus hand-coded in each project in this book LLBLGen Pro You will not be able to follow any of the code samples in this book without the retail version of LLBLGen Pro You may be asking yourself, “Aren’t those programs expensive? Why not it by hand?” Our answer is “These programs save time!” We prioritize speed (but not at the expense of reliability or maintainability) and, therefore, recommend to you that you consider how much time and energy these programs can save you and not only the prices of the products Looking at the projects developed in this book will serve as a good example (Figure 1.2) While you could write the same Windows application by hand without Visual Studio, the automation that Visual Studio affords can be tremendous In our example application alone, about 68% of the code in the Windows application project is generated automatically Most of this code is written as elements in the GUI are configured visually; only 32% of the code was completely written by hand And the differences are even more pronounced using LLBLGen Pro in the application’s class library, which contains the business logic and data access layer (these terms are discussed later) In this project, over 98% of the code is automatically generated What the developer adds by hand amounts to a mere 1,139 lines of code—less than 2% (Keep in mind that this application is in the beginning stages of development, and that for this reason you will be adding much more custom code.) Another benefit of the code written by Visual Studio and LLBLGen Pro is that it is well commented, well spaced, and easy to read, adding to the line count of generated code The main point here, however, is that with these tools you can take a great leap forward on Windows projects and projects that use databases Automating repetitive code is a major part of rapid development, and it is worth paying for Now, let’s take a look at the other concepts and principles that make this method of development a desirable choice O/R Mappers An O/R Mapper creates classes defining objects that correspond to the structure of your database Every row becomes an entity and every table becomes an entity collection The fields of the database table become public properties of the entity object The framework also builds in constructors and other useful methods to find entity objects, set their properties, and save them back to the database with just a few lines of code Figure 1.3 Two related database tables Deployment Deployment Now that we have configured all the publishing options, click Publish Now to build and publish the AW.Win application You will receive a notice in the status bar that will tell you if the publish was successful If you elected to have the HTML file open upon publication, you will now see a web page pop up like in Figure 11.10 Clicking on the Install button will install the application Installation could not be easier! Before we install the application, though, let’s take a look at what Visual Studio generated for us behind the scenes If you open the publish location that you specified, you will see something like Figures 11.11 and 11.12 Figure 11.11 Project AW.Win main application deployment folder Notice that in the main application folder, you get an HTML file, a setup.exe file, and several manifest files Visual Studio organizes each version in its own folder by version and build number This makes it easy to keep a history Inside each version folder are all the necessary executables and DLL files Figure 11.12 Project AW.Win version-specific folder Installation Now let’s install the application to test the deployment settings You can install the application on your development machine or test it on another client machine Click on the Install button in the HTML file to install AW.Win If you handled certificates and code-signing correctly, you should not be prompted with any other questions You will see a status window open as in Figure 11.13 121 Chapter 11 Figure 11.13 ClickOnce installation status bar If there are no unexpected errors, the application should install and execute (if you configured it that way) If the connection between your machine and the publish location is fast (like over a local area network), the process is quite speedy Figure 11.14 Project AW.Win installation location The application will appear inside the Add/Remove Programs control panel, but where the files actually reside? Strangely enough, the files are not in C:\Program Files as you might expect In Figure 11.14, you will see where the AW.Win application installed on a test machine It goes into the Profile folder of the currently logged on user in C:\Documents and Settings, inside the Local Settings folder which is hidden, and in a folder called Apps Now you have successfully installed the AW.Win application If you also checked the option to make it available offline, you will have a shortcut in your Start menu to launch the application at a later time From now on, you can go back to the Properties of your AW.Win project (Figure 11.5) and click Publish Now to build and deploy the latest changes to the same location When a new version of the software is available, your users will be prompted to install it automatically when the application opens or closes (depending on the configuration) In the next chapter, we will look at how to make changes to the database and migrate them into your application 122 Regenerating Code 12 Regenerating Code “It is a bad plan that admits of no modification.” Publilius Syrus (1st Century B.C.) Chapter Goals • Learn the cycle of regenerating LLBLGen Pro code without losing custom changes • Make minor changes to database field names or relationships and propagate changes to your application • Make major changes to the table names and propagate changes to your application Inevitable Changes Throughout the development of our application, we have focused on speed We want to get a working application as quickly as possible and at the same time create a good framework to further developer the application, writing as much reusable code as possible Now we are going to show you how to make drastic changes the the schema of your database and propagate those changes to your application You may be asking, “why didn’t we just plan better and make those changes at the beginning before we started?” Ideally, the kinds of changes we are about to discuss would be made at the beginning of a project But, since ideal situations are rare, we are trying to simulate the “real world” as much as possible Many developers will inherit projects that were already started without making good decisions at the beginning And perhaps all developers will build applications based on requirements that change after development has already started In any case, we will almost certainly be in a position where we need to make drastic changes to the database and update our application with all the changes LLBLGen Pro and Visual Studio make this process as painless as it can possibly be Let’s look at the process for making changes and regenerating your code Minor Changes To begin, we will start with some fairly minor changes What are minor changes? Adding new entities, typed lists, typed views are minor changes Changes to columns names in the database, column data types, and the names of relationships are other examples The process of making these less involved changes is easy and efficient First, we need to make some changes to the AdventureWorks schema in SQL Server Open SQL Server Management Studio Make a full backup of your database by right-clicking on the database, and selecting Tasks > Backup Save a backup file in a safe location In SQL Server Management Studio, make the column name changes according to Table 12.1 in the AdventureWorks database 123 Chapter 12 Table SalesOrderDetail Old Column Name OrderQty New Column Name Database Dependencies Quantity LineTotal calculated formula, CK_SalesOrderDetail_OrderQty constraint, as well as removing/altering the trigger associated with the table SalesOrderHeader TaxAmt TaxCost TotalDue calculated formula, CK_SalesOrderHeader_TaxAmt constraint SalesOrderHeader Freight ShipCost TotalDue calculated formula, CK_SalesOrderHeader_Freight constraint SalesOrderHeader TotalDue TotalCost Table 12.1 AdventureWorks database column name changes Now, we can open our LLBLGen Pro project that we created in Chapter and update it with these schema changes If Visual Studio is open, close it now Open LLBLGen Pro and open your AW.Data LLBLGen Pro project file Select File > Preferences Ensure that the SyncMappedElementNamesAfterRefresh option is set to false (Figure 12.2) Figure 12.2 LLBLGen Pro preferences screen If this option happened to be set to true, then a change in the name of a field in the database would also change the corresponding entity property name If you would rather not create breaking changes in your code, you can set this option set to false, which is the default Generally, keeping the column names and entity properties the same will 124 Regenerating Code avoid unnecessary confusion We will make our breaking changes manually here in order to have more control over them Another property you can set is the CleanUpVsNetProjects option When selected, this option will update your Visual Studio project file to keep it current with any file names that might change in the regeneration process With our minor changes, no code file names will change, but as we make major changes, this option will be useful to enable Keep in mind that LLBLGen Pro cleans the project file by removing all files in the project and re-adding the files that were just generated This cleaning-up process will remove old files from the project that are no longer needed, but if you have added extra files manually (as we did with the SalesOrderHeaderEntityValidator.cs and Utility.cs file that we created in Chapter 8) you will have to add them again to your project after regenerating your code Set the CleanUpVsNetProjects option to true Click Save to close the Preferences screen Go to Project > Refresh All Catalogs You will be prompted with this ominous, but necessary warning (Figure 12.3) Click Yes and proceed confidently Figure 12.3 Schema update warning Next, you will be prompted with the same database selection screen you saw when you first set up your project (Figure 12.4) Figure 12.4 Database selection screen 125 Chapter 12 Choose the same database server, username, password and database catalog as you did in the beginning Select Retrieve schema(s) (Optionally, you can elect to select Project > Unattended Refresh of All Catalogs instead of Refresh All Catalogs to bypass this screen if the settings to connect to your SQL database are always the same.) LLBLGen Pro will scan the schema again and make the appropriate changes to your project After the process has finished, you will get a screen summarizing the changes that were made to your project (Figure 12.5) Figure 12.5 Catalog refresh results screen Notice that all the changes we made were found As of this moment, we have not introduced any breaking changes into our Windows application Our data layer has adjusted to the change in the schema and isolated the upper application layers from this change Next, we will go ahead and make the field name changes in the SalesOrderDetail and SalesOrderHeader entities, so that the field names will match the database column names Right-click on the SalesOrderDetail entity and select Edit / Properties Change the name of the OrderQty column to Quantity Right-click on the SalesOrderHeader entity and select Edit / Properties Change the name of the TotalDue column to TotalCost, the Freight column to ShipCost, and the TaxAmt column to TaxCost We will also make a few other changes while we have this screen open Remember in Chapter 6, when we added all the properties to the SalesOrderHeaderEntity class which exposed rows from the CustomerViewRelated entity (Example 6.1)? Let’s add all those properties to our LLBLGen Pro project, so LLBLGen Pro will take care of exposing those properties for us In the SalesOrderHeader entity edit screen, click on the Fields on related fields tab Add new related fields from the CustomerViewRelated entity for FirstName, LastName, City, StateProvinceName, CountryRegionName, and PostalCode (Figure 12.6) These breaking changes should be enough for now Let’s regenerate the AW.Data project with the settings in Figure 12.7 Save the project, by going to File > Save Project Go to Project > Generate Select Self-Servicing, Two Class Scenario (Base Classes Only) 126 Regenerating Code Figure 12.6 Entity SalesOrderHeader fields on related fields screen Selecting the Self-Servicing, Two Class Scenario (Base Classes Only) configuration will ensure that our custom code is not overwritten All of the other settings should be same as they were when we first generated our code By only regenerating the base classes, which contain all the field definitions, the entities we use will be updated, while everything we customized will remain untouched Before generating, if you want to ensure that any particular file is not overwritten, you can set the read-only flag of the file to true (right-click on the file in Windows Explorer and select Properties) Click Start Generator Figure 12.7 Generator settings screen 127 Chapter 12 Figure 12.8 Generation process results screen The process will begin, and we will receive the notification when it is finished (Figure 12.8) You can browse these results to see which items have been regenerated and which have been preserved Notice that the entity classes have been preserved as well as the validator classes Now open your AW solution again in Visual Studio Enable the Show All Files option in Solution Explorer (Figure 12.9) This option will help us to see items that are in the same folders as the project, but not part of the project Remember that LLBLGen Pro cleaned up our project file and we need to add the SalesOrderHeaderEntityValidator.cs file and the Utility.cs file back to our project Right-click on both files and select Include in Project Without making any other changes, compile the AW.Data project The AW.Data project compiles without a problem We have no custom code in the entity classes that needs to be updated We have properties in the SalesOrderHeader entity that we have defined manually, and in our LLBLGen Pro project Both properties reveal the same information from the related entity under two different names, and it now makes sense to remove the old ones Although there are no breaking changes in the AW.Data project, we will find some breaking changes in our AW.Win project Try to compile the AW.Win project There are errors that we will need to correct before we can compile (Figure 12.10) Notice that of these errors were in DataGridView columns If we had not updated the DataPropertyName property to point to the field index, we might have missed these changes! Update all the references in the AW.Win project until it compiles As you build and run the application, you should notice that it now operates the way it did before the schema changes This result means there are no runtime errors We changed the schema of the database and in a few minutes updated our data access layer, making the necessary changes in our custom code, and bringing our application back to the full working state it was before we started THAT is one of the best advantages of using the techniques in this 128 Regenerating Code Figure 12.9 Solution Explorer Show All Files toggle book This kind of development may not be glamorous, but it will definitely save you hours and days of code maintenance and run-time bug hunting Major Changes Now we will make some major changes to the database Unless you enjoy painful, tedious processes, you probably will not this very often, but it is a useful topic to understand Major changes include changing table names or drastically altering the schema (adding/removing/redesigning tables) In the case of table name changes, the underlying names of the class files themselves will change as they are based on the names of the table If you find yourself completely overhauling your schema, you might want to start from a brand new generated data and business logic layer and then migrate over your custom code from your old project For this example, we will just be making a few changes to table names in order to show you how to handle them without starting over from a new Visual Studio project In the AdventureWorks database, the schema is well organized and normalized: it is not screaming for changes like the old Northwinds example database that used to be included with SQL Server We will however, change some of the Figure 12.10 Project AW.Win compilation errors 129 Chapter 12 table names anyway to practice doing so A complaint one might make about the AdventureWorks schema is the long names for the order-related tables It seems logical that the name OrderHeader would work as well as SalesOrderHeader and save unnecessary typing Close Visual Studio, open up SQL Server Management Studio again, and make changes to table names according to Table 12.11 Old Table Name New Table Name SalesOrderHeader OrderHeader SalesOrderDetail OrderDetail SalesOrderHeaderSalesReason OrderHeaderSalesReason Table 12.11 AdventureWorks table name changes Changing the table and fields names may break stored procedures and other dependent database objects If you want affected objects to continue operate, you will need to fix them in SQL Server Now we can update our LLBLGen Pro project Open LLBLGen Pro and select Project > Unattended Refresh of All Catalogs You should be notified by the program that of the tables in our project that were renamed (the OrderHeaderSalesReason table is not in our project) We need to change the names of entities manually if we want them to be the same as the table names in our database now The relationships between the entities will also need to be updated, since the field name is based on the entity name Because the entities and relationship objects make a large number of changes, it is easier to delete the entity from the project and re-add it Delete the SalesOrderHeader and SalesOrderDetail entities from the project Re-add both entities to the project We also need to restore the relationship we created in the Chapter between the OrderHeader entity and the customer view we added as an entity in Figure 2.16 This relationship exists only in our LLBLGen Pro project and not in the database Regenerate your code with the Self Servicing, two class scenario (Full/Safe) Visual Studio 2005 configuration to the same folder you used before This option will try to regenerate all the files (base classes, entity classes, and Visual Studio project files), but not overwrite any files that already exist For our situation, this option is what we need Since the OrderHeader and OrderDetail tables are “new”, we need the base class files and the business logic classes But we not want to lose the ones that we have already customized Once your regeneration is complete, open Visual Studio and your AW Solution Enable the Show All Files option in Solution Explorer Remember that LLBLGen Pro cleaned up our project file and we need to add the SalesOrderHeaderEntityValidator.cs file and the Utility.cs file back to our project Copy and paste your custom code from the old SalesOrderHeaderEntity class to the new OrderHeaderEntity class Also move code from the SalesOrderDetailEntity class to the new OrderDetailEntity class You will need to make changes to class names in your code as necessary Continue migrating and updating code in the AW.Data and AW.Win project until you can get the solution to compile again 130 Regenerating Code You can use the Find and Replace function to save time, but be careful: you might end up changing more than you intend! If you find that you have made unexpected changes, you can always close the tabs that open automatically without saving the changes You will notice that there are a lot of breaking changes in these projects! This process of updating code should take about 30 minutes Considering the number of changes to our database, the time is well spent Also, remember that we are catching these breaking changes at compile-time and not run-time It would take considerably longer to testing on all the features in our application if the errors were all run-time errors Compile and run the application The application should now operate just like it did before the schema changes! We just made major changes to the schema of our database, and, in less than an hour, propagated those changes to the application If we had many hardcoded strings in our code that referenced table names and column names, we would still need to take more time to fully purge the old names from the system Having a reliable process for maintaining your code ensures that your application will be flexible enough to evolve as the needs of your organization change, which they almost certainly will A wise developer prepares not only for the expected, but also for the unexpected! 131 Appendix Free Icons Microsoft has included free icons with Visual Studio that can add a professional look to your applications The graphics are located in a ZIP file inside the Visual Studio installation folder (C:\Program Files\Microsoft Visual Studio 8\Common7\VS2005ImageLibrary\VS2005ImageLibrary.zip) Once you unzip the files, you can begin using them in your projects To add an icon to a ToolStripButton Select the ToolStripButton and click the button in the Image property Select Import and browse to the location where you unzipped the files Select the picture you wish to import Select Open, and then OK to close the Select Resource window You will need to select the color that should be transparent in order for the control to render properly without a background Change the ImageTransparentColor property of the ToolStripButton to Black (for most icons in the library) Here are some useful icons you might want to use in your project: Afterword “The most important development in your life is not the programs you write, but the kind of person you are becoming.” The Author We have finished the life cycle of this example application, but your journey has just begun As you have followed these examples, you have been able to see why the methods presented here are a powerful way to build an application quickly, without sacrificing maintainability While the application at this point has only a few features, it is a powerful framework to build on Hopefully, you have come to appreciate how the combination of Visual Studio NET 2005, LLBLGen Pro, and SQL Server 2005 automates repetitive tasks more efficiently than you could on your own, while leaving you the flexibility to extend the framework to meet your specific needs and implement your business logic You have also been exposed to the advantages of using dynamic SQL and seen how your application becomes more maintainable by working with strongly-typed objects You have been able to take advantage of the newer Visual Studio features to work with code visually, and you have seen how easy it is to deploy a Windows application Each of these techniques applies to web applications as well Because so much of our logic is moved to the bottom tiers of our application, porting the Adventure Works application to the web would be quite easy It is my hope that this book has been helpful to you as a developer Please drop me an email with your comments and suggestions, or just give me your email address so that I can notify you as the book is updated Also, if you would like to see more titles like this one, let me know as well Joseph Chancellor josephchancellor@gmail.com www.lulu.com/josephchancellor ... Rapid C# Windows DEVELOPMENT Visual Studio 2005, SQL Server 2005, & LLBLGen Pro Quickly Build Robust, Database-Driven Applications Joseph Chancellor © Joseph Chancellor 2006 Rapid C# Windows. .. project can be a C# Class Library, C# Windows Application, or a C# Web Application In our case, we will have two main projects: AW.Data, the generated data/business layer, which is a C# Class Library... language construction Chapter Figure 1.10 A strongly-typed DataSet in a C# Windows project Native language filter construction in C# is a helpful and time-saving new feature in LLBLGen Pro, and throughout