# Saturday, October 25, 2008

LINQ to SQL external mapping file

With LINQ to SQL you can choose to use an external mapping file, allowing you to map SQL statements to CLR objects (also referred to as POCO, Plain Old CLR Objects). Doing so means you do not need to adorn your classes with attributes.
Here's a little sample of how to do this.

public class Supplier
{
    public int ID { get; set; }
    public string Name { get; set; }
}
 
public List<Supplier> GetSupplier( string name )
{
    SqlConnection conn = new SqlConnection( cConnectionString );
 
    XmlMappingSource xms = XmlMappingSource.FromUrl( @"mapping.xml" );
 
    var db = new DataContext( conn, xms );
 
    Table<Supplier> Suppliers = db.GetTable<Supplier>();
 
    var query = from s in Suppliers
                where s.Name == name
                select s;
 
    return query.ToList();
}
 
 

The XML can be as simple as:

<?xml version="1.0" encoding="utf-8"?>
<Database Name="VideoGameStoreDB"
          xmlns="http://schemas.microsoft.com/linqtosql/mapping/2007">
  <Table Name="dbo.Supplier" Member="Supplier">
    <Type Name="Supplier">
      <Column Name="SupplierID" Member="ID" />
      <Column Name="SupplierName" Member="Name"  />
    </Type>
  </Table>
</Database>
 

You can use SQLMetal (a command line tool included with Visual Studio) to generate a mapping file.

#    Comments [0] |
# Wednesday, October 15, 2008

SDN Conference 2008

The SDN Conference 2008 was a great success, thanks to all the speakers and attendees for making it so!

Beth Massi has a great write up on the day after the conference, the traditional Holland Tour: http://blogs.msdn.com/bethmassi/archive/2008/10/14/holland-tour.aspx.

Time to start working on SDN Conference 2009 :-)

#    Comments [0] |
# Monday, September 29, 2008

Visual Studio Team System Developer & DBPRO Edition become one

Microsoft has put up a page to inform us about the next version of Visual Studio,  it is called Visual Studio Team System 2010.

Part of the new deal is a change in licensing, the fun part is: the licensing change takes effect on October 1st 2008!!!

Those of you who subscribe to MSDN and will now have access to both the Developer and DBPro edition of VSTS:

Better Together – Visual Studio Team System Development Edition and Database Edition
In recognition of the increased need to integrate more of the lifecycle members together, we will provide a unified Development and Database product in Visual Studio Team System 2010. Beginning October 1, 2008 Development Edition and Database Edition MSDN subscribers will have access to both products.

#    Comments [0] |
# Saturday, September 27, 2008

Promoting DiscountASP.NET

I just answered an email asking for a referral to a good hosting place, thought I'd blog about my experience with my hosting provider.

I've been running my blog and website with DiscountASP.NET for the last 3 years and never had an incident. They offer ASP.NET 3.5 hosting and usually offer options to test beta versions of ASP.NET or SQL Server as well, which is something I like. They're not the cheapest, but in my opinion, worth the money.

Click the banner to go to their site.

In the spirit of transparency: The link contains a referral code which will generate a kickback for me :-)

#    Comments [0] |

Maine Developer Network & MSDN Roadshow

The Maine Developer Network is helping out the MSDN Roadshow. Thanks to Shawn we're able to have the MSDN Roadshow come as far north as Augusta, ME. On October 3rd the Developer Evangelists for the New England region: Chris, Bob and Jim will be up (or down) in Augusta to present the latest and greatest .NET technologies. A full day of FREE training, open to everyone!

Sign up here: http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032387795&culture=en-US

Topics are:

  • Understanding the ADO.NET Entity Framework
  • Discovering Dynamic Data
  • Exploring Internet Explorer 8
  • RoboLunch
  • UI, UX, U Confused?
  • A RESTed Development
  • Befriending Unit Testing

Location:

Riverview Psychiatric Center
250 Arsenal Drive
Sebago Room Augusta Maine 04332-0011
United States

There will be give aways and ofcourse plenty of fun people to meet!

#    Comments [0] |
# Saturday, September 06, 2008

Strive to improve

Here is a good reason to always keep improving:

:-)

#    Comments [1] |
# Wednesday, September 03, 2008

SDN Conference 2008

Registration for the SDN Conference 2008 is open. Visit: www.sdc.nl

SDN Conference

#    Comments [1] |
# Saturday, August 30, 2008

Workflow designer faster in SP1

According to Matt Winkle some performance enhancements have been made to the Workflow designer in Visual Studio 2008 SP1. Strangely enough no mention of these improvements is made in the release notes. I wonder if they made it in.

Matt Winkle: "In .NET 3.5 SP1, there are no features introduced, but there have been a number of internal improvements made, including some substantial perf gains in the WF designer (for certain scenarios)."

#    Comments [0] |
# Friday, August 29, 2008

Workflow scheduling

Windows Workflow scheduling services manage how workflow instances are scheduled by the workflow runtime engine. Whether they are handled in an asynchronous manner through the DefaultWorkflowSchedulerService, or in a manual, synchronous manner through the ManualWorkflowSchedulerService, these services are an important part of your workflow solution.

The application I'm working on right now uses ManualWorkflowScheduler, so I needed to figure out the exact differences between the two scheduler, luckily MSDN actually offers pretty clear documentation:

Default Workflow Scheduler Service

DefaultWorkflowSchedulerService is used by the workflow runtime engine by default. It creates and manages the threads that run workflow instances in an asynchronous manner on the workflow runtime engine. Workflows that are waiting to run are stored in the internal queue of the DefaultWorkflowSchedulerService . When the DefaultWorkflowSchedulerService wants to start a workflow, a thread is acquired from the .NET Framework thread pool and used to run the workflow. The MaxSimultaneousWorkflows property determines how many simultaneous threads the scheduler service will allow at one time. If the limit is four, for example, the DefaultWorkflowSchedulerService will acquire up to four threads from the .NET Framework thread pool to execute the workflows. If four workflows are already running, additional work items (workflows) are placed in the queue and eventually executed as threads become available. The following figure shows how the DefaultWorkflowSchedulerService executes workflows in an asynchronous manner.

defaultworkflowscheduler

You can set the maximum number of workflow instances that can be active at any one time by passing a parameter to the DefaultWorkflowSchedulerService constructor or by using an application configuration file. Task 1: Configure Runtime Services Using Code shows how to configure the DefaultWorkflowSchedulerService class by using the constructor. Task 2: Configure Runtime Services using App.Config shows the same configuration of the DefaultWorkflowSchedulerService but uses an application configuration file.

Manual Workflow Scheduler Service

The ManualWorkflowSchedulerService provides a threading service that enables the host application that creates a workflow instance to donate the Thread on which the workflow instance is run. Using this threading service, host applications can run a workflow instance on a single Thread (that is, in synchronous mode). This mode blocks the execution of the host application until the workflow instance becomes idle. Subsequently, the workflow instance can only be executed by using the RunWorkflow method of this service.

Alternatively, the workflow can be run on a thread created by a .NET timer by setting the useActiveTimers constructor parameter to true. When this timer expires, the workflow is executed on the timer's thread, rather than the host application's thread. This timer is implemented as a DelayActivity activity.

ManualWorkflowSchedulerService controls the number of threads spawned in an ASP.NET process by reusing the thread that made the ASP.NET Web request to run the workflow instance. This ensures that at any time, the number of active threads in the workflow runtime equals the number of active Web requests in the ASP.NET process.

ManualWorkflowSchedulerService does not automatically run a workflow instance that is in the queue. The host must call RunWorkflow to run a specified workflow.

#    Comments [0] |

Workflow designer is slow

The workflow designer in VS2008 can sometimes be a little sluggish. I ran across a post on the forum which offers the following advice:

Commonly reported issues

1. Time taken to open a workflow document is long.

2. Opening Activity bind dialog is slow.

Reasons for slow down

The Workflow designer relies on parsing the source code in the current project to provide updated design information in workflow design surface, rules dialog intellisense etc. This is mainly to enable scenarios where picking up changes from the source even before the project has been rebuilt.

Tips to make designer perform better

1. Move all types used in workflows to a different project than where the workflows live.

Move interfaces, event types, custom activities, helper classes to a different project than in which the workflow resides. E.g. in the solution from a customer, there were about 10 project, with 10 workflows each and 10 associated event types. These types are all reparsed to update to build the design time type information every time the user changes workflows in the project. Moving these to a different assembly e.g  just one project with all the types needed for the 10 workflow projects will help improve performance.

2. Reduce the number of workflows in a project.

Each workflow is a type ( directly in c#/vb, and indirectly in xoml case) that needs a design time type to be built by parsing, so if there are 10 workfows in a project, opening any workflow in the project for the first time means parsing all the other workflows as well. Classifying these workflows based on their function and grouping them in 2-3 workflows per project improved performance drastically.

3. Re-Factor large state machine workflows into smaller workflows

One example we found from a customer had 780 states and 1000 activity binds in the same workflow, leading to a InitializeComponent() of about 16000 lines. Factoring this state machine into smaller reusable workflows will making designer performance much better, and reduce a lot of redundant states.

4. Don’t do long running work in activity constructors

Activity constructors are called during design time also, so doing things like connecting to a database etc should never be done in constructors, this can make the designer take too long to open workflow documents using these activities.

#    Comments [0] |

Fixes and changes in Visual Studio 2008 SP1 and .NET 3.5 SP1

Visual Studio 2008 SP1 and .NET 3.5 SP1 offer an extensive list of enhancements, but also of bug fixes, here are the links in case (like me) your looking for a specific fix:

http://support.microsoft.com/kb/950263/ - List of changes and fixed issues in Visual Studio 2008 Service Pack 1

http://support.microsoft.com/kb/951845/ - List of changes and fixed issues in Visual Studio 2008 Service Pack 1 for Team Editions 

http://support.microsoft.com/kb/950264/ - List of changes and fixed issues in Visual Studio 2008 Service Pack 1 for Express Editions

http://support.microsoft.com/kb/951847/ - List of changes and fixed issues in Visual Studio 2008 Service Pack 1 for the .NET Framework 3.5

#    Comments [0] |
# Wednesday, August 27, 2008
# Friday, August 22, 2008

From Delegate to Lambda

The article wrote for Code Magazine, named 'From Delegate to Lambda', about understanding the transition from delegates to lambdas has been published in the September issue and can also be found online at: http://www.code-magazine.com/Article.aspx?quickid=0809081.

#    Comments [4] |
# Monday, August 11, 2008

SDN Conference 2008

The annual geekfest, the Software Development Network Conference 2008 is being held on the 6th and 7th of October at the Leeuwenhorst in Noordwijkerhout (close to Amsterdam).

The list of speakers and sessions has been published and the Early Bird discount applies until August 16th. So sign up now.

#    Comments [0] |

2nd Dutch Code Camp

After last years success, three user groups in the Netherlands are again coordinating their efforts to create the 2nd Dutch Code Camp.

Interested in speaking or attending? Sign up here.

#    Comments [0] |

Tenth Boston Code Camp: DEV inTENsity

Chris Bowen and and a group of volunteers is putting together the TENTH Boston Code Camp. Call for speakers is out right now. So go ahead and volunteer to speak at this great event!

#    Comments [0] |

Speaking at the BAND

Tomorrow night I'll be the guest speaker at the BAND (Bangor Area .NET Developers user group). I'll be talking about Workflow Foundation.

Workflow Foundation (WF) is one of the pilars of .NET 3. If you think WF is an end user tool then you’re wrong. It is a framework targeted at software developers that want to embed workflow into their custom applications. This session will explore the WF basics and focus on implementing State Machine Workflows, how to use the workflow runtime and where Windows Communication Foundation fits in the whole picture.

Sign up here.

#    Comments [0] |
# Sunday, August 03, 2008

VirtualPC images on a USB Flash Drive

I use a VirtualPC environment for all my software development work, usually using a unique environment for every customer. This eats up the drive space in my laptop pretty darn quick. So after reading about running a VirtualPC image from a USB Flash Drive I decided to give it a try. I purchased a 32GB memory stick and plugged it in.

After a little experimenting I can now confirm it runs the VirtualPC nice and fast. But writing data to the disk and reading at the same time is horrendously slow. So you need to do two things:

a) Make sure the .vmc file is NOT located on the flash drive
b) Enable UndoDisks

These two steps will create a temporary file on your harddisk, in the folder where the .vmc is located. This means that while using the drive you only read from the flash drive, but never write.

When you shut down the VPC you can choose to commit the changes to the flash drive, this may take a little while, so only do it when you have time to wait for it to complete.
I usually choose 'Save State' which allows me to restart the VPC where I left off.

#    Comments [0] |
# Friday, August 01, 2008

XSD.exe turns integer into string

If you're using the xsd.exe tool to generate C# code from an XML Schema you'll find that an attribute defined as an integer is generated into a string field.

The reason is listed on MSDN:

The xs:integer type is specified as a number with no upper or lower bound on its size. For this reason, neither XML serialization nor validation map it to the System.Int32 type. Instead, XML serialization maps the xs:integer to a string while validation maps it to the Decimal type that is much larger than any of the integer types in the .NET Framework.

#    Comments [0] |
# Wednesday, July 30, 2008

What is a Software Architect?

Ted Neward offers a very good description of what a Software Architect is:

"an architect is not like a construction architect, but more like the conductor of a band or symphony. Yes, the band could play without him, but at the end of the day, the band plays better with one guy coordinating the whole thing. The larger the band, the more necessary a conductor becomes. Sometimes the conductor is the same thing as the composer (and perhaps that's the most accurate analogous way to view this), in which case it's his "vision" of how the music in his head should come out in real life, and his job is to lead the performers into contributing towards that vision. Each performer has their own skills, freedom to interpret, and so on, but within the larger vision of the work."

#    Comments [0] |