# Tuesday, September 22, 2009

I will be doing my Daily Scrum talk and a keynote on Silverlight 3.0 Line of Business features at the Basta! Fall conference from September 21-25th in Mainz, Germany. Hope to see you there.

image

posted on Tuesday, September 22, 2009 2:43:50 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Sunday, September 20, 2009

Every fall, the kids go back to school, the weather gets cooler, Munich kicks off its annual Oktoberfest festival, and the fall conference season heats up. It seems that I always miss Oktoberfest. I had friends who lived in Munich earlier this decade and each year my trips to Mt. Everest got in the way. Now that Telerik has a Munich office, I got to go to Oktoberfest (O#) with geeks. I can see the eyes rolling by the non-technical readers of this blog (basically my Mom is the only non-technical person who reads this blog), however, geeks can drink a lot, judging by how I had to crawl up the spiral staircase in my hotel room last night. (Yes you read that right. I also thought that European rooms were suppose to be small. I think that the staircase is a cruel joke for Oktoberfest and they only give the room to dumb, obnoxious Americans, but I digress.)

IMG_0270

 

While I am here to talk about the future direction of OpenAccess and how to further evolve the WCF Wizard that I recently wrote a blog series on, we all will be headed up to Mainz for Basta 2009. Since the fall conference season is upon us, I figured I will outline here all of the events I will be speaking at this fall, plus a special trip to Nepal I want to tell you about.

Basta! 2009, Mainz, Germany 21-25 September

This is my first Basta event, but many of my colleagues have spoken there for years (including fellow RDs and ex RDs Ingo Rammer, Markus Egger, and Christian Weyer.) and have raved about the passion of the audience. I’ll be speaking on scrum as well as doing a keynote on Silverlight’s line of business applications (this keynote will be one long demo.) Telerik is also going to be there, as a sponsor and with a booth. We have enough tee-shirts for every man, woman, and child at the conference. Should be fun!

School building in Chyangba Village, Nepal, 25 September-October 6

Instead of going to Mt. Everest this year, I will be going to my sherpa’s home village and help construct a library for the local school. I am also going with a few other geeks like Richard Campbell, Kathleen Dollard, and Maciej Pilecki. We are raising money for the village and trying to set up an endowment. I would love to see the tech community help us. Since speakers don’t get paid for these events, my tagline this fall will be asking for geeks to donate to the cause. (Hey if people can “walk” for cancer, I can speak for a village.) More on this on a blog post later this week before I fly to Kathmandu, but you can sponsor here. I have to thank Telerik for being so supportive of this passion of mine.

DevReach, Sofia, Bulgaria 12-13 October

DevReach is another passion of mine since the conference founder Martin Kulov reached out to me for help in planning the first ever DevReach in 2006. It is also how I met the Telerik boys. It is also how I discovered how beautiful Bulgarian women are. All of that said, it is a great show, now in our 4th year and of course Telerik is a huge sponsor and will have a great presence there. I’ll be doing the scrum session as well as Data Access Hacks and Shortcuts and Building RESTful Applications with Microsoft tools.

CodeCamp, Cracow, Poland 17 October

Fellow RD Tad Golonka, who is totally awesome, introduced me to the crazy country of Poland (also another land of beautiful women, seeing a trend??) Long story short, but if you remember I was the global recruiter for the Curing Cancer project, and one of the folks I hired was Szymon Kobalczyk (also recommended by Tad.) Szymon, who says I have changed his life (I just hope for the better!), runs the CodeCamp, so I could not say no! Talking scrum and data as well and I expect to have a great time.

Software Developers Conference (SDC),  Arnhem, The Netherlands, 19-20 October

This will be my 12th year of speaking at SDC (something like 15 events) and my first SDC was back in May 1998. The SDC took a chance on a young inexperienced speaker (I only spoke at a few Advisor DevCons in the United States before then) and I am forever grateful. To be honest, I have no idea why the Dutch like me so much, I constantly show up for sessions drunk (one year they even put the word “Beer” in my session title (start listening at 22 minutes in)) and insult Dutch people. I got very drunk and very abusive in 2007 and they made me do a keynote in 2008. I guess I am not learning. That said, I will be back with the usual cast of characters.  This is my favorite event of the year.

Tech*Days Hong Kong 2-4 November

This will be my first time speaking at Tech*Days in Hong Kong. There are usually a few thousand folks at this event and I will doing a session called “Sharing Code between .NET and Silverlight” as well as my Daily Scrum talk. Looking forward to this one!

Tech*Ed Europe, Berlin, Germany 9-13 November

After setting a TechEd record of doing 10 sessions last year (only to break that record and do 11 in LA this year), the TechEd Europe organizers figured that they had enough of me and only assigned me 2 sessions (Estimation and “Agile Tools and Teams”.) I lost track, but I think this is my 10th TechEd in Europe! Telerik will be there in force with a booth and developers staffing the booth. This should be a great event.

PDC 2009, Los Angeles, California (why?!) 17-19 November

While PDC is pretty much a Microsoft only speaker event talking about future technology, Joel and I will be doing a BOF session on Agile Tools and Teams. Basically a repeat of our BOF at TechEd in LA (and my session in Berlin.  Watch this related video.) Telerik will be at the PDC in full force, as a sponsor and with a booth. Known for great software and also awesome must have t-shirts, we will have over 1,000 copies of our new t-shirt, making its debut at PDC. Stop by the booth for that (as well as .NET Ninjas, Geeketts, and some others.) Also Telerik will be unveiling its newest product and will have demos all week will give away licenses.

That is a lot of events, but it will be great! Hope to see you at one (or all)!

posted on Sunday, September 20, 2009 6:14:45 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Friday, September 18, 2009

Over the past few weeks I have showed how to use Telerik OpenAccess with the WCF Wizard. I think that this wizard is a crucial piece of technology since I hate to write plumbing code myself, it takes me too long and I usually make mistakes.

I wish that SQL Azure would provide RESTful and WCF services wrapped around your database tables and views with just a check box in the Azure management page. But alas, I can dream. Until that day arrives, you will have to code the services yourself. So I decided to do it with OpenAccess and WCF (and of course the Wizard.)

First you need to get some data up in SQL Azure. Refer to my post from a few weeks ago as how to do that. Next you have to create a data access layer with Telerik OpenAccess. But you have to create your DAL against a local SQL Server 2005/2008 database with the same schema as the one up in SQL Azure. You have to do this because SQL Azure does not support querying of the schema. After you map your tables to classes (I will do just Customers for this demo), you have to go in and change the connection string in your DAL’s app.config to use SQL Azure instead of the database you used for the mapping:

   1:    <connection id="Connection1">
   2:      <databasename>Northwind_Lite</databasename>
   3:      <servername>tcp:tpzlfbclx1234.ctp.database.windows.net</servername>
   4:      <integratedSecurity>False</integratedSecurity>
   5:      <backendconfigurationname>mssqlConfiguration</backendconfigurationname>
   6:      <user>Stevef</user>
   7:      <password>gomets!</password>
   8:    </connection>

Now you have to create the WCF service via the wizard (if you forgot how to do that, watch this video). This will be done in a separate project to achieve a full separation of concerns.

image

After you create the WCF service via the Wizard, you can go ahead and create a Silverlight client. Your solution set up should consist of a DAL project, a WCF service project, a Silverlight web project, and a Silverlight client project.

image

 

Ok, XAML time. (In my head I am saying that to the tune of Hammer Time, but I digress….)  I will create a grid that will bind to the CompanyName, ContactName, City, and Phone fields of the Customer table. The grid will do most of the magic for us. I will also add a “Refresh” button as well as a “Save” button. The Refresh button will have the same LoadData() method as in all of my previous blog posts. We’ll talk about Save in a minute.

   1:  <data:DataGrid x:Name="dataGridCustomers" Grid.ColumnSpan="4" ItemsSource="{Binding}">
   2:      <data:DataGrid.Columns>
   3:          <data:DataGridTextColumn Binding="{Binding Path=CompanyName}"
   4:  Header="Company Name"></data:DataGridTextColumn>
   5:          <data:DataGridTextColumn Binding="{Binding Path=ContactName}" 
   6:  Header="Contact Name"></data:DataGridTextColumn>
   7:          <data:DataGridTextColumn Binding="{Binding Path=City}"
   8:   Header="City"></data:DataGridTextColumn>
   9:          <data:DataGridTextColumn Binding="{Binding Path=Phone}"
  10:   Header="Phone"></data:DataGridTextColumn>
  11:      </data:DataGrid.Columns>
  12:  </data:DataGrid>

 

If we run our application, you can see that the grid works as advertised, fetching data from SQL Azure.

image

I’ll go in and edit the city for the first record to say “Hong Kong.” In order to facilitate this, we need to handle the BeginEdit event of the grid. During this event handler shown below, we will stuff a Customer object into our own private collection so we know that the entity is dirty. (If we don’t do this, we won’t know which items are dirty and would have to update all of them, a big waste of resources.) I do this on line 9 (after a check to see if it already in my collection.)

   1:  void dataGridCustomers_BeginningEdit(object sender,
   2:                    DataGridBeginningEditEventArgs e)
   3:  {
   4:      //build a list of Customer that are dirty
   5:      Customer customer = e.Row.DataContext as NorthwindWCFService.Customer;
   6:   
   7:      if (!editedCustomers.Contains(customer))
   8:      {
   9:          editedCustomers.Add(customer);
  10:      }
  11:  }

Now we have to handle the button click. (When the user hits save.) The user can hit save after editing the entire page (or after each row if they prefer, but find me a user who wants to do that.) The code below calls the WCF service we created with the wizard asynchronously. In this case we call the service for each customer in our collection (loop is from lines 8-111, the call to the WCF service is online 10).

 
   1:   
   2:  void ButtonSave_Click(object sender, RoutedEventArgs e)
   3:  {
   4:      SampleWCFServiceClient client = new SampleWCFServiceClient();
   5:   
   6:      client.UpdateCustomerCompleted += UpdateCustomerCompleted;
   7:      //save only the dirty customers
   8:      foreach (NorthwindWCFService.Customer customer in editedCustomers)
   9:      {
  10:          client.UpdateCustomerAsync(customer.CustomerID.ToString(), customer);
  11:      }
  12:   
  13:  }

 

In the code directly above, we registered an event, UpdateCustomerCompleted, to fire when each Customer is done updating. In theory we don’t need to do anything as far as the data is concerned, however, we have to clean up our collection of dirty Customers (line 8) as well as set an internal counter to 0 (line 7). This will give us a clean slate when we start editing again. We will also use the opportunity to show a message box (line 10) to the user that the data was updated. (Yea, yea I know I need error handling, etc. This is a demo!! :) ) We do this clean up only after all Customers have been edited and their async calls have been caught. We do this with our counter (line 3 and 5), comparing our count to the number of dirty records. Old school, but effective.

   1:  void UpdateCustomerCompleted(object sender, UpdateCustomerCompletedEventArgs e)
   2:  {
   3:      this.updatedCount++;
   4:   
   5:      if (updatedCount == editedCustomers.Count)
   6:      {
   7:          updatedCount = 0;
   8:          editedCustomers.Clear();
   9:   
  10:          MessageBox.Show("All Customers have been updated successfully!",
  11:                                                "Updating Data", MessageBoxButton.OK);
  12:      }
  13:  }

 

You can see the results here.

image

So let’s do one last thing. Let’s add a client side filter. This will be a dirt simple one, using LINQ to Objects to filter for only customers in Germany. (Of course the filter should be dynamic, etc. Also you may want to move this functionality to the server via your WCF Service.)

In the XAML page, I provide a checkbox that says “Show only Germany.” When this is checked we will filter our results with a LINQ statement. When it is unchecked, we will show all the records.

image

Our LoadData() method calls the WCF service and registered an event, ReadCustomersCompleted. LoadData() is called on the page load, refresh button click, and check box click events.

In past demos, this just took the result and assigned it to the ItemSource property of the grid. In this case we will check to see if our filter check box is checked (Line 6) and if so, we will perform a LINQ query (Lines 8-10) and assign the result to the gird (Line 12). If the check box is not checked, we perform no filter (line 16).

 

   1:  void ReadCustomersCompleted(object sender, 
   2:                   ReadCustomersCompletedEventArgs e)
   3:  {
   4:      //if the filter is set use a LINQ statement
   5:      //this can also be done on the server via the service
   6:      if (CheckFilter.IsChecked == true)
   7:      {
   8:          var filter = from c in e.Result
   9:                       where c.Country == "Germany"
  10:                       select c;
  11:   
  12:          dataGridCustomers.ItemsSource = filter;
  13:      }
  14:      else
  15:      {
  16:          dataGridCustomers.ItemsSource = e.Result;
  17:      }
  18:  }

 

That is it! Of course you can create nice add and delete dialogs as well, it is just as easy.

Enjoy!

posted on Friday, September 18, 2009 6:37:59 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Thursday, September 17, 2009

As I showed yesterday, the new version of the Telerik OpenAccess WCF Wizard now allows you to work with any version of OpenAccess. Here is a video of how to do that by .NET Ninja in training Peter Bahaa.

Telerik OpenAccess WCF Wizard: How-to Video #6-Auto detection of OpenAccess Version from Stephen Forte on Vimeo.

posted on Thursday, September 17, 2009 4:19:58 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Wednesday, September 16, 2009

When the Telerik OpenAccess WCF Wizard shipped last month, it only worked with the Q2 version of OpenAccess. The problem is that Telerik makes internal builds of a product available in-between releases so developers can play around with new bits faster-and the OpenAccess WCF Wizard did not work with them. Telerik Internal Builds fix bugs out of band so lots of folks us them. The feedback we got on the WCF Wizard is that the wizard should work with any version of OpenAccess, including internal builds.

image

The latest version of the Telerik OpenAccess WCF Wizard does just that. Now when you open the Wizard and you attempt to connect to a data access layer built by a version of OpenAccess that the Wizard does not understand, a versions store dialog will come up as shown below. The dialog will tell you what version of OpenAccess the DAL was created with and you will have to navigate to the Telerik.OpenAccess.dll file and add it to the versions store. You will also have to exit the wizard and come back in. Once you have done so, you are free to use the wizard with that version of OpenAccess. You will also be allowed to use older versions that are saved in the store.

image

Enjoy!

posted on Wednesday, September 16, 2009 2:46:40 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Tuesday, September 15, 2009

The following video shows how to use the updated Telerik OpenAccess WCF Wizard with ATOMPub services via the WCF REST Starter Kit. The video is done by .NET Ninja in training Peter Bahaa and uses the same ATOMPub project I showed yesterday on my blog. Enjoy!

Telerik OpenAccess WCF Wizard: How-to Video #5: ATOMPub Property Selection from Stephen Forte on Vimeo.

posted on Tuesday, September 15, 2009 1:12:44 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Monday, September 14, 2009

Last week I showed how to use the Telerik OpenAccess WCF Wizard to automatically create a feed in Atom Syndication Format using the WCF REST Starter Kit’s Visual Studio project templates. Based on the feedback we have gotten from the community on the ATOMPub projects, Telerik has refreshed the WCF Wizard (go download it now) to enhance the ATOMPub projects.

Let’s take a step back first. The Atom Syndication Format is for feeds, similar to RSS. So when you run the project that we looked at in my blog last week in default IE 8 (or IE 7) feed view, it would look something like this. This is no different from what my feeds look like from CNN and ESPN, etc.

image

But how did IE decide what to put as the title or the description of each item in the feed? (And since we are just exposing OpenAccess entities as feeds, the real question is which properties (or database fields at the end of the day) did IE choose for you?)

If you go back to IE settings and turn off feed view (which I always recommend when working with Astoria, REST Collection, and ATOMPub services) you can view the raw XML.

image

As shown in raw XML ATOM feed below in lines 3 and 4 you can see that the Company Name and Contact name were randomly placed into those fields (and that is how IE uses that data to display.) Well it was not randomly selected, I just hard coded those two fields in my demo. For applications these two fields are usually ignored. But it would be nice to have them set to something useful.

   1:  <entry>
   2:    <id>ALFKI</id> 
   3:    <title type="text">Alfreds Futterkiste</title> 
   4:    <summary type="text">Maria Anders</summary> 
   5:    <updated>2009-09-14T08:16:30Z</updated> 
   6:   
   7:    <category term="customers" /> 
   8:  - <content type="text/xml">
   9:  
  10:    <Address>Obere Str. 57</Address> 
  11:    <City>Berlin</City> 
  12:    <CompanyName>Alfreds Futterkiste</CompanyName> 
  13:    <ContactName>Maria Anders</ContactName> 
  14:    <ContactTitle>Sales Representative</ContactTitle> 
  15:    <Country>Germany</Country> 
  16:    <CustomerID>ALFKI</CustomerID> 
  17:    <Fax>030-0076545</Fax> 
  18:    <Phone>030-0074321</Phone> 
  19:    <PostalCode>12209</PostalCode> 
  20:    <Region i:nil="true" /> 
  21:    </Customer>
  22:    </content>
  23:    </entry>

 

The latest version of the WCF Wizard will now give you a dialog, so you don’t have to alter the code at all. As you can see from the screen shot below, the wizard now gives us a drop down so we can choose which property to expose in feed view as the title and description. So just to be different, I will choose the company name as the title and the Address as the description.

image

 

When we look at the raw ATOMPub XML you will see Company Name and Address in lines 3 and 4.

   1:  <entry>
   2:    <id>ALFKI</id> 
   3:    <title type="text">Alfreds Futterkiste</title> 
   4:    <summary type="text">Obere Str. 57</summary> 
   5:    <updated>2009-09-14T08:47:12Z</updated> 
   6:     
   7:    <category term="customers" /> 
   8:  - <content type="text/xml">
   9:  
  10:    <Address>Obere Str. 57</Address> 
  11:    <City>Berlin</City> 
  12:    <CompanyName>Alfreds Futterkiste</CompanyName> 
  13:    <ContactName>Maria Anders</ContactName> 
  14:    <ContactTitle>Sales Representative</ContactTitle> 
  15:    <Country>Germany</Country> 
  16:    <CustomerID>ALFKI</CustomerID> 
  17:    <Fax>030-0076545</Fax> 
  18:    <Phone>030-0074321</Phone> 
  19:    <PostalCode>12209</PostalCode> 
  20:    <Region i:nil="true" /> 
  21:    </Customer>
  22:    </content>
  23:    </entry>

 

If you view the service in feed view in IE, you will now see the Company Name and Address as the title and description.

image

Of course this did not effect our Silverlight front end since the application just ignored those fields. Those fields are available to the application, but we did not use them (we only used two fields (company name and contact name from the main XML tree.)

image

posted on Monday, September 14, 2009 9:08:51 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Friday, September 11, 2009

When SQL Data Services (now SQL Azure) released its first CTP it did not look anything like SQL Server: there were no tables, stored procedures, views, etc. With the new CTP, SQL Azure embraces SQL Server in the sky and supports the relational model, including stored procedures. This is good since there are millions of lines of stored procedures out there in production today and migrating them to SQL Azure is pretty easy.

I decided to give a simple stored procedure a test drive. I opened up SQL Management Studio, started a new query, entered in my SQL:

   1:  CREATE Procedure sel_CustomerOrder   
   2:  @CustomerID char(5)   
   3:  AS
   4:  SELECT o.OrderID, o.OrderDate,  p.ProductName,   
   5:       (od.UnitPrice*od.Quantity)-((od.UnitPrice*od.Quantity)*od.Discount) as TotalCost   
   6:  FROM orders o   
   7:       inner join [order details] od   
   8:              on o.OrderID=od.OrderID  
   9:       inner join products p  
  10:              on od.ProductID=p.ProductId  
  11:  WHERE CustomerID=@CustomerID
  12:  ORDER BY o.OrderID

 

I hit F5 and all was right with the world. So I decided to try it out:

Exec sel_CustomerOrder @CustomerID='ALFKI'

And got the expected results.

image

You can now use this stored procedure in all the applications that you connect to since SQL Azure supports standard ADO.NET connection strings. Pretty cool.

posted on Friday, September 11, 2009 12:48:44 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback