← Back to all blogs


Posts in 'dotnet'

Using FlexGrid as an advanced ListBox

This brief post shows how to create a ListBox type control which mimics the one used in Microsoft Access.

Epic AdventureWorks Part 2 - The Model

This article is the second of a four part series: Epic AdventureWorks Part 1 - The Blueprints Epic AdventureWorks Part 2 - The Model Epic AdventureWorks Part 3 - The Web App Epic AdventureWorks Part 4 - The Style Check out the AdventureWorks ASP.NET Sample ASP.NET app online. If you haven't already figured it out, we are going to use the AdventureWorks 2008 sample database from codeplex to build against. We wanted to use something that was: A relational database model A full scale database with real world data Familiar to most developers We also made sure not to build anything that required changes to the database schema or data in order to work. The purpose of this goal is that developers can plug this app into the AdventureWorks database they might already have installed. About the AdventureWorks database The AdventureWorks OLTP database supports standard online transaction processing scenarios for a fictitious bicycle manufacturer (Adventure Works Cycles). Scenarios include Manufacturing, Sales, Purchasing, Product Management, Contact Management, and Human Resources. AdventureWorks is used in code examples in SQL Server Books Online and in companion samples that can be downloaded from the Microsoft SQL Server Samples and Community Projects home page. The database schema is designed to showcase SQL Server features. The AdventureWorks data model is relational and uses alot of good practices in doing so. For this reason, the database might be someone cumbersome to those of you used to more flattened samples from Microsoft. Luckily, they published some helpful articles that map AdventureWorks to the older and flatter sample databases. If you are a hardcore Northwind fanboy then you might enjoy this AdventureWorks to Northwind Table Comparison. And if you are really old school then you should check out this AdventureWorks to pubs Table Comparison. The entire data model is well-documented and can be seen on this AdventureWorks Data Dictionary and this SQL Server Objects in AdventureWorks. Here is a great diagram depicting the whole database model and its entities. Check out the complete data model: AdventureWorks2008.pdf Building the Model Since AdventureWorks is a large and fairly complex database, I did not want to write an entire business model for it. I chose to use Entity Framework to generate a model for me. AdventureWorks is well-structured so I figured Visual Studio would do a good job of auto-generating the model from the database schema. Let's look at how we can easily generate a Entity Framework model from an existing database. First we need to "Add New Item" to the project and select "ADO.NET Entity Data Model". Next we will choose to "Generate from database". We are choosing this option since the database is already well-structured and matches the model we want to work with. For highly normalized databases it is sometimes better to start with an empty model and add model views that merge tables to build useful objects. For this application I have embedded the database inside the App_Data folder so we will choose to generate our model from the MDF file itself. I only chose this option because we will be making this application available for download and I did not want to require you all to install a separate instance of AdventureWorks on a SQL Server. Next I will select which object in the database we want to add to the entity model. I am choosing all since I want to be able to work with Tables, Views and Stored Procedures included in the database. This dialog allows you to drill down to specific data objects in case you want to explicitly include or exclude objects (like a legacy Table).   Click finish and BOOM, we have a full object model to work with including methods for Updates, Inserts and Deletes. Below is the model we generated in minutes. As you can see, it is quite substantial and would take a long time to develop manually! Thank you ADO.NET Entity Framework for making my life easier. Wow, that was easy. Extending the Model Now that we have a fairly complete object model, I want to extend it to make it more usable. The first thing I want to do is expose the data through a Web Service so we can work with the model on the client-side. I don't know what is easier: generating an ADO.NET Entity Data Model or exposing an entire ADO.NET Entity Data Model as a Web Service. To start, I "Add New Item" and select "WCF Data Service" Visual Studio will generate the following code for the code behind the Web Service. using System;using System.Data.Services;using System.Data.Services.Common;using System.Collections.Generic;using System.Linq;using System.ServiceModel.Web;public class DataService : DataService< /* TODO: put your data source class name here */ >{ // This method is called only once to initialize service-wide policies. public static void InitializeService(IDataServiceConfiguration config) { // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc. // Examples: // config.SetEntitySetAccessRule("MyEntityset", EntitySetRights.AllRead); // config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All); }}

PDF Acroforms in WinForms

Deep in the ComponentOne Laboratories, our developers have been envisioning new and improved ideas to enhance our current controls. This is no different with ComponentOne Print Preview for WinForms. A major enhancement has been made to Print Preview for WinForms: forms can now be exported to PDF Acroforms. In previous versions of Preview for WinForms, RenderInput controls were exported to PDF simply as images, whereas now they are exported to PDF as form fields. With you - the developer - in mind, ComponentOne has included four supported controls: Text, RadioButton, ComboBox, and CheckBox.

Silverlight 4 Business Application Development for Beginners at NWA TechFest

July 8 at 10:30 AM - Learn how to complete development tasks crucial to business applications such as implementing simple page navigation, creating dialog windows, and styling controls. In this Webcast, we?ll develop a Silverlight application from the ground up so beginners can learn how a Silverlight application works. And then we'll start diving right into more intermediate tasks. And since this is geared towards business application development, we?ll also cover different ways to access data in Silverlight. This session will be using Visual Studio 2010 and Silverlight 4.

Using Licensed WinForms controls in WPF

Did you know that you can use licensed WinForms controls in WPF applications? It's true.

Extreme Form Makeover with C1Ribbon

What is a Ribbon?

Firefox Slow When Browsing Localhost

For all of you Web Devs out there like me that use many browsers during development, you may have noticed how slow Firefox can be when debugging web apps in Visual Studio. The issue is one of the IT variety and I dare not try to explain it. So here is the solution...

Working with Silverlight 4 to Build an Image Editor

With the official release of Silverlight 4, many familiar features are now possible out of the box. These features include drag and drop management, handling the right mouse button click, and printing. While most of these features were already possible using ComponentOne Silverlight 3 controls, Silverlight 4 adds value and flexibility to our studio as we continue to push the limits of the framework itself.

Hot off the build machine: Silverlight 4 controls!

Well, we actually made the controls available yesterday through prerelease. But today they are officially on the ComponentOne site!

Tweet! Tweet!

I am going to start posting quick little tips and tricks to twitter and hope you will follow me! I will also be happy to answer any questions and would love your feedback!