# Saturday, March 13, 2010

This week Telerik released a new LINQ implementation that is simple to use and produces domain models very fast. Built on top of the enterprise grade OpenAccess ORM, you can connect to any database that OpenAccess can connect to such as: SQL Server, MySQL, Oracle, SQL Azure, VistaDB, etc. While this is a separate LINQ implementation from traditional OpenAccess Entites, you can use the visual designer without ever interacting with OpenAccess, however, you can always hook into the advanced ORM features like caching, fetch plan optimization, etc, if needed.

Just to show off how easy our LINQ implementation is to use, I will walk you through building an OData feed using “Data Services Update for .NET Framework 3.5 SP1”. (Memo to Microsoft: P-L-E-A-S-E hire someone from Apple to name your products.) How easy is it? If you have a fast machine, are skilled with the mouse, and type fast, you can do this in about 60 seconds via three easy steps. (I promise in about 2-3 weeks that you can do this in less then 30 seconds. Stay tuned for that.)

 Step 1 (15-20 seconds): Building your Domain Model

In your web project in Visual Studio, right click on the project and select Add|New Item and select “Telerik OpenAccess Domain Model” as your item template. Give the file a meaningful name as well.

image

Select your database type (SQL Server, SQL Azure, Oracle, MySQL, VistaDB, etc) and build the connection string. If you already have a Visual Studio connection string already saved, this step is trivial.  Then select your tables, enter a name for your model and click Finish. In this case I connected to Northwind and selected only Customers, Orders, and Order Details.  I named my model NorthwindEntities and will use that in my DataService.

image

Step 2 (20-25 seconds): Adding and Configuring your Data Service

In your web project in Visual Studio, right click on the project and select Add|New Item and select “ADO .NET Data Service” as your item template and name your service.

image

In the code behind for your Data Service you have to make three small changes. Add the name of your Telerik Domain Model (entered in Step 1) as the DataService name (shown on line 6 below as NorthwindEntities) and uncomment line 11 and add a “*” to show all entities. Optionally if you want to take advantage of the DataService 3.5 updates, add line 13 (and change IDataServiceConfiguration to DataServiceConfiguration in line 9.)

   1:  using System.Data.Services;
   2:  using System.Data.Services.Common;
   3:   
   4:  namespace Telerik.RLINQ.Astoria.Web
   5:  {
   6:      public class NorthwindService : DataService<NorthwindEntities>
   7:      {
   8:          //change the IDataServiceConfiguration to DataServiceConfiguration
   9:          public static void InitializeService(DataServiceConfiguration config)
  10:          {
  11:              config.SetEntitySetAccessRule("*", EntitySetRights.All);
  12:              //take advantage of the "Astoria 3.5 Update" features
  13:              config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
  14:          }
  15:      }
  16:  }

 

Step 3 (~30 seconds): Adding the DataServiceKeys

You now have to tell your data service what are the primary keys of each entity. To do this you have to create a new code file and create a few partial classes. If you type fast, use copy and paste from your first entity,  and use a refactoring productivity tool, you can add these 6-8 lines of code or so in about 30 seconds. This is the most tedious step, but don’t worry, I’ve bribed some of the developers and our next update will eliminate this step completely.

Just create a partial class for each entity you have mapped and add the attribute [DataServiceKey] on top of it along with the key’s field name. If you have any complex properties, you will need to make them a primitive type, as I do in line 15. Create this as a separate file, don’t manipulate the generated data access classes in case you want to regenerate them again later (even thought that would be much faster.)

   1:  using System.Data.Services.Common;
   2:   
   3:  namespace Telerik.RLINQ.Astoria.Web
   4:  {
   5:      [DataServiceKey("CustomerID")]
   6:      public partial class Customer
   7:      {
   8:      }
   9:   
  10:      [DataServiceKey("OrderID")]
  11:      public partial class Order
  12:      {
  13:      }
  14:   
  15:      [DataServiceKey(new string[] { "OrderID", "ProductID" })]
  16:      public partial class OrderDetail
  17:      {
  18:      }
  19:   
  20:  }

 

Done! Time to run the service.

Now, let’s run the service! Select the svc file and right click and say “View in Browser.” You will see your OData service and can interact with it in the browser.

image

Now that you have an OData service set up, you can consume it in one of the many ways that OData is consumed: using LINQ, the Silverlight OData client, Excel PowerPivot, or PhP, etc.

Happy Data Servicing!

Technorati Tags: ,,

Bookmark and Share
posted on Saturday, March 13, 2010 4:29:07 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Thursday, March 11, 2010

Love LINQ to SQL but are concerned that it is a second class citizen? Need to connect to more databases other than SQL Server? Think that the Entity Framework is too complex? Want a domain model designer for data access that is easy, yet powerful? Then the Telerik Visual Entity Designer is for you.

Built on top of Telerik OpenAccess ORM, a very mature and robust product, Telerik’s Visual Entity Designer is a new way to build your domain model that is very powerful and also real easy to use. How easy? I’ll show you here.

First Look: Using the Telerik Visual Entity Designer

To get started, you need to install the Telerik OpenAccess ORM Q1 release for Visual Studio 2008 or 2010. You don’t need to use any of the Telerik OpenAccess wizards, designers, or using statements. Just right click on your project and select Add|New Item from the context menu. Choose “Telerik OpenAccess Domain Model” from the Visual Studio project templates.

image

(Note to existing OpenAccess users, don’t run the “Enable ORM” wizard or any other OpenAccess menu unless you are building OpenAccess Entities.)

You will then have to specify the database backend (SQL Server, SQL Azure, Oracle, MySQL, etc) and connection.

image

After you establish your connection, select the database objects you want to add to your domain model. You can also name your model, by default it will be NameofyourdatabaseEntityDiagrams.

image

You can click finish here if you are comfortable, or tweak some advanced settings. Many users of domain models like to add prefixes and suffixes to classes, fields, and properties as well as handle pluralization. I personally accept the defaults, however, I hate how DBAs force underscores on me, so I click on the option to remove them.

image

You can also tweak your namespace, mapping options, and define your own code generation template to gain further control over the outputted code. This is a very powerful feature, but for now, I will just accept the defaults.

 image

When we click finish, you can see your domain model as a file with the .rlinq extension in the Solution Explorer.

image

You can also bring up the visual designer to view or further tweak your model by double clicking on the model in the Solution Explorer. 

image

Time to use the model!

Writing a LINQ Query

Programming against the domain model is very simple using LINQ. Just set a reference to the model (line 12 of the code below) and write a standard LINQ statement (lines 14-16).  (OpenAccess users: notice the you don’t need any using statements for OpenAccess or an IObjectScope, just raw LINQ against your model.)

   1:  using System;
   2:  using System.Linq;
   3:  //no need for an OpenAccess using statement
   4:   
   5:  namespace ConsoleApplication3
   6:  {
   7:      class Program
   8:      {
   9:          static void Main(string[] args)
  10:          {
  11:              //a reference to the data context
  12:              NorthwindEntityDiagrams dat = new NorthwindEntityDiagrams();
  13:              //LINQ Statement
  14:              var result = from c in dat.Customers
  15:                           where c.Country == "Germany"
  16:                           select c;
  17:   
  18:              //Print out the company name
  19:              foreach (var cust in result)
  20:              {
  21:                  Console.WriteLine("Company Name: " + cust.CompanyName);
  22:              }
  23:              //keep the console window open
  24:              Console.Read();
  25:          }
  26:      }
  27:  }

Lines 19-24 loop through the result of our LINQ query and displays the results.

image

That’s it! All of the super powerful features of OpenAccess are available to you to further enhance your experience, however, in most cases this is all you need.

In future posts I will show how to use the Visual Designer with some other scenarios. Stay tuned.

Enjoy!

Technorati Tags: ,,

Bookmark and Share
posted on Thursday, March 11, 2010 9:26:16 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Wednesday, March 03, 2010

In an op-ed piece in this month’s SD Times, I make the argument that software development productivity tools have evolved over the years to become more mainstream. I make the case that while some developers shun tools, in reality they take for granted the tools they are using today that were not available 10 years or so ago, or were not that mature. For example today we use some tools without even thinking such as: SCM, build management, standards enforcement, ORM and UI components. Tools today save a team a tremendous amount of time and are the missing link in the software development process.

You can get the March issue of SD Times on the newsstands today or read my article online here.

Technorati Tags:

Bookmark and Share
posted on Wednesday, March 03, 2010 3:09:36 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Friday, February 26, 2010

We had a great Agile seminar yesterday in Pune, India. You can download the seminar slides here.

A special thanks to Telerik, the Mahratta Chamber of Commerce, Industries and Agriculture and the team from e-Zest for planning such a successful event. Usually as the speaker I get all the glory, so here is the photo of me with the folks who made it happen, they deserve the glory:

image

Technorati Tags: ,

Bookmark and Share
posted on Friday, February 26, 2010 3:37:27 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Monday, February 22, 2010

Telerik has released the latest beta of the OpenAccess Data Service Wizard. We now support Visual Studio 2010 RC! You can also choose to use WCF 4.0 as one of the services you can build. Based on your feedback we also added a new feature: the ability to automatically generate dependent entities.

Download it today and give us your feedback. Next stop is the full release as part of our 2010 Q1 release of OpenAccess. See the OpenAccess roadmap here.

 image

Technorati Tags:

Bookmark and Share
posted on Monday, February 22, 2010 10:13:20 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Monday, February 15, 2010

The story of human achievement is almost always one of teamwork. While we celebrate individual accomplishments, like Neil Armstrong stepping foot on the moon, it is always the team that makes or breaks the effort. I have always been interested in why teams succeed; it is easy to figure out why teams fail. A lot of time we think that we need a team of “Ninjas” in order to succeed, or a superstar team leader. In reality we need neither the Ninja team nor rock star team leader. For better or worse, I have been leading teams for a long time and I maybe a decent team leader now, but I was not early in my career-I have made every mistake in the book! Upon reflection of my past successes and failures I recently turned my attention to the question of why do teams succeed?

The problem with answering that question is that each team is different and even if you measure one team over a period of time, chances are that they worked on different projects or with different users, so it is difficult to get reliable observations. To gain some reliable observations you would have to observe one team working on virtually the same project, with virtually the same users, over a short period of time.

The good news is that I did just that. About 10 years ago during the .COM boom, I was the team leader of a team that was working on a website. (Surprise, surprise back then!) We worked on two short iterations (we did not call them that since this was before “Agile”) that were very similar in scope and requirements and worked for the same users. One iteration failed completely (the second one) and one was a smashing success (the first one). What was the key difference between these iterations? Everything was the same, the users and the developers got along, all key members were engaged, all the requirements were clear. What was different?

During the first and more successful project , I was on the “disabled list”. My ankle and leg were hurt while rock climbing and I had to walk around with a silly cane. (My doctor wanted crutches, but I refused.) It hurt to walk, even to stand, so I tended to stay put in one place at a time. As luck would have it, this company was an aspiring .COM, so they had leased a ridiculous amount of office space since they were going to hire 500 more people overnight. (Remember those days?) Since it hurt to walk, I usually just camped out with the business users at a spare desk.

Sometimes I overheard something the users would say that would affect the system and just butt on in that conversation. Sometimes they wanted to bounce things off my head and since I was right next to them, we had a lot of ad hoc meetings. This produced a better quality of communication. Studies have shown that there are thousands of communication "points" delivered with facial expressions and verbal tones/speech patterns. This gets lost in email, documents, etc.

Besides the close proximity to the business users, the development team would be around a lot too. While email was popular back then, I believed (and still do) that in-person communication is better, so I would not reply often to emails (especially vacation requests), forcing my introverted developers to ask me things face to face. This lead to other mini-meetings with the users and developers; business users would also overhead a team member coming to me lobbying to cut or add a feature and butt into that conversation with their perspective.

When the second project started, I was almost healed, so I tended to hang out in the IT department more often. (I also started to walk around with a baseball bat instead of a cane, that that would frighten people who did not know me.) As I said before the second project was a big failure and we later figured out that my leg was the only variable that had changed. For the next project iteration, we made it a rule to have a technology person sitting with the business team. (The guy who suggested this won the first shift with the users.) The collaboration between the business team and the technical team was the deciding factor and I have stressed team collaboration ever since, and my career has been the better for it.

You may be thinking that this is impossible in today’s day and age with distributed teams and rapidly changing requirements. The company I co-founded a few years back, Corzen, employed this strategy, even though we had a distributed team with both remote employees and overseas contractors. At our Corzen headquarters in New York City, we had our seating arrangements in an “open” style where the business team and the technology teams all sat together at desks right on top of each other alongside the sales team. While it at times did suck (like when my girlfriend would call and everyone could overhear our conversation), it paid many dividends. When the salesperson obviously lost a sale because of a lack of a feature that you lobbied against, it is far more powerful to hear the play by play in real time than getting an angry email from him later on.

Corzen had remote employees as well as overseas contractors, and we collaborated and communicated well with them. Of course we could not have them sit with us in the “bullpen” as we called it, but we did involve them on very frequent calls and webinars with our business team. The business team would make all of their documents available on a share or Google documents and over-share information instead of under-share. During the design phases the team would always communicate well and keep that communication going almost daily. New team members were inserted all the time and would come up to speed very rapidly. Of course the technical team held daily scrums using Skype and reported both ways (to the tech team and the business team) what was going on. This process was so successful that it lead to a great deal of success and Corzen was acquired by a larger entity based in another country and it still operates this way.

So if I have to sum it all up and answer the question why do teams succeed, the answer is pretty easy: communication, collaboration, and being “in the flow” of the emerging process. I have always known this, but my experiences described above enabled me to re-discover it. The best teams can finish each other sentences. Successful projects that I worked on had high bandwidth communication and extremely small feedback cycles. Success projects communicate and work "the way humans" should work - more face to face, more verbal. They also didn't rely up documentation to collaborate/communicate need/specification. Users don’t have all the answers, the requirements and features need to be discovered jointly by having a technical team member embedded with the users, or tools that mimic the fluidity of being together. Toyota perfected this process twenty years ago; the agile movement that started ten years ago was a recognition of this, so we have the knowledge of what works and what doesn’t work on projects. Embrace collaboration, communication, and work “the way humans” work (or mimic that fluidity if your team is remote) and you will have successful projects all the time.

 

Technorati Tags:

Bookmark and Share

posted on Monday, February 15, 2010 2:46:36 PM (Eastern Standard Time, UTC-05:00)  #    Comments [4] Trackback
# Tuesday, February 09, 2010

.NET Ninja in training, Peter Bahaa, shows us how to build an AtomPub Endpoint using Telerik OpenAccess entities and the Data Services Wizard beta 1.

Telerik Data Services Wizard Beta1-ATOMPub from Stephen Forte on Vimeo.

Technorati Tags: ,,

Bookmark and Share
posted on Tuesday, February 09, 2010 4:11:38 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Saturday, February 06, 2010

Check out my pre-con at TechEd North America, Joel and I will be speaking on Agile. Register here. :)

PRC07 The Agile Methodology Demystified: Implementing Agile in Your Organization

Track: Development Practices

Speaker(s): Joel Semeniuk, Stephen Forte

Agile project management and development methods are being adopted at many development shops. After an introduction to the basics of Agile and Scrum, including: project planning and estimation, the Scrum Master, team, product owner and burn down, and of course the daily Scrum, certified scrum masters Stephen and Joel show many real-world applications of the methodology drawn from their own experience. Negotiating with the business, estimation, and team dynamics are all discussed as well as how to use Scrum in small organizations, large enterprise environments, and consulting environments. Next we discuss using Scrum with virtual teams and an off-shoring environment. We then take a look at some of the planning tools we will use for Agile Estimation, including planning poker, Microsoft Visual Studio Team Foundation Server 2010, and much more. We dive into some agile developer techniques such as TDD, Continuous Integration, and Dependency Injection, and round out the pre-con with a discussion on Agile developer tools and how they can help (and sometimes hinder) the development process. The speakers have a very interactive style so participation is encouraged and there will be plenty of time for Q&A. This seminar is a jump start for preparing for a scrum master certification.

 

Technorati Tags:

Bookmark and Share
posted on Saturday, February 06, 2010 3:56:32 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Friday, February 05, 2010

.NET Ninja in training, Peter Bahaa, shows us how to build a WCF Endpoint using Telerik OpenAccess entities and the Data Services Wizard beta 1.

Telerik Data Services Wizard Beta1-REST Collection from Stephen Forte on Vimeo.

Technorati Tags: ,,

posted on Friday, February 05, 2010 7:12:26 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Thursday, February 04, 2010

 SQL Server Modeling (formerly "Oslo") is a new model driven development paradigm. Developers can model their applications using the new M language. M allows you to define a structure for your data as well as represent it in graph based values. Representing values in the M language is very similar to JSON, which will allow you to represent your data in name/value pairs. Here is an example of M values in action:

People
{
     { Id=>1, Name=>"Steve", Age=>36},
     { Id=>2, Name=>"Mike", Age=>29}
}

Last summer, Telerik created the industry’s only LINQ to M (Values) implementation. The Telerik LINQ to M implementation allows the developer to use pure LINQ statements with blocks of M values, pure text or the results of a transformed DSL. With the new SQL Server Modeling November CTP there are some changes to the M specification, so we have updated our core DLLs to accommodate this. Download it for free here. Shoot me any feedback you have.

image

Enjoy!

Technorati Tags: ,,
posted on Thursday, February 04, 2010 2:50:39 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Wednesday, February 03, 2010

.NET Ninja in training, Peter Bahaa, shows us how to build a WCF Endpoint using Telerik OpenAccess entities and the Data Services Wizard beta 1.

Telerik Data Services Wizard Beta1-WCF from Stephen Forte on Vimeo.

Technorati Tags: ,
posted on Wednesday, February 03, 2010 1:55:44 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Tuesday, February 02, 2010

.NET Ninja in training, Peter Bahaa, once again returns to show us how to build a WCF .NET Data Service (aka Astoria) using Telerik OpenAccess entities and the Data Services Wizard beta 1.

Telerik Data Service Wizard Beta1-Astoria from Stephen Forte on Vimeo.

 

Technorati Tags: ,
posted on Tuesday, February 02, 2010 1:55:39 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Tuesday, January 26, 2010

Do you know Excel? Answer a few quick questions at the Excelerators Quiz site, and find out how you rate. Let me know your results and you could even win a brand new HD monitor from Microsoft! The prize you can win will include a Dell ST2310 23 inch flat panel monitor, keyboard, and mouse. (Over $250 value.)

Here is how you can win the goods:

Go take the quiz and report here your results in the comments, or ping me on Facebook. Take the quiz between today and February 4th. I will decide the winner and send the results to Microsoft. (Tiebreaker will be a PowerPivot challenge I will dream up.)

This is one of only 5 or so “official” blogs where you can win; you can only enter once. :) You also have to be a US citizen to win (sorry to my buddies in Hong Kong!).

Good luck!

 

 

 

 

 

Technorati Tags:
posted on Tuesday, January 26, 2010 10:10:08 AM (Eastern Standard Time, UTC-05:00)  #    Comments [13] Trackback
# Monday, January 25, 2010

I’ll be speaking at the Great Indian Developer Summit from April 20-23 at the Indian Institute of Science in Bangalore, India. This will be my second time to the GIDS and it will be hard to top last year’s adventure of Video Drivers, Prison Riots, and Silverlight, but I will try.

developersummit (1)

I will be speaking on .NET day on:

  • Business Intelligence Design Patterns: BI Made Easy!
  • Sharing Code between .NET and Silverlight (This is mostly on SL 3.0, but will I show how you can do it with SL 4.0 too, which is *much* easier!)

On web day I will be speaking about:

  • Building Line of Business Applications with Silverlight 4.0

Sessions are only 50 minutes, so almost no slides and almost all demo.

For the Friday Seminar, I will be doing a 3 hour workshop on Agile and Scrum. I am going to try to make this completely interactive. If you are going for a Certified Scrum Master or Certified Scrum Developer, this is a great head start.

Telerik will be a Silver Sponsor and should have a booth and (if the customs agents like us) lots of Telerik Tee shirts to give away.

Hope to see you there!

posted on Monday, January 25, 2010 9:25:19 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Saturday, January 23, 2010

Last week Telerik released the Data Service Wizard Beta 1. It will automatically create for you the end points for an Astoria, WCF, or RESTful service. New in the beta of the Data Service Wizard is the ability of the wizard to automatically generate the DataServiceKey attribute required to make relationships in Astoria work.

When you use "Astoria" (ADO.NET||WCF) Data Services, by default Astoria tries to map the primary keys in your entities using a convention. This is important for your service to work. The mapping works out of the box for the Entity Framework, however, if you are using LINQ to SQL or Telerik Open Access, it does not since some of your tables may have a primary key that will not map to the CLR primitive types that follow the Astoria convention for key mapping. (Order Details in Northwind bombs for example since both of its composite key are entities and not primitive CLR types.)

There is a very simple fix for this. You have to make your entity a partial class and then decorate the entity using the DataServiceKey attribute, in the constructor. Recently we added support for this in the Data Service Wizard: by default we do this for you by adding a “DalDataServiceKeys.cs“ (or VB) file to your data access layer project automatically.

image

The code is show below for our DalDataServiceKeys.cs file shown in the Telerik.OA.DAL project above. You will notice on Line 36 we will even convert the complex type to a primitive CLR type so Astoria can handle it.

   1:  namespace Telerik.OA.DAL
   2:  {
   3:      using System.Data.Services.Common;
   4:   
   5:      /// <summary>
   6:      /// Category Class Data Service Key Fix
   7:      /// </summary>
   8:      [DataServiceKey("CategoryID")]
   9:      public partial class Category
  10:      {
  11:      }
  12:      /// <summary>
  13:      /// Customer Class Data Service Key Fix
  14:      /// </summary>
  15:      [DataServiceKey("CustomerID")]
  16:      public partial class Customer
  17:      {
  18:      }
  19:      /// <summary>
  20:      /// Employee Class Data Service Key Fix
  21:      /// </summary>
  22:      [DataServiceKey("EmployeeID")]
  23:      public partial class Employee
  24:      {
  25:      }
  26:      /// <summary>
  27:      /// Order Class Data Service Key Fix
  28:      /// </summary>
  29:      [DataServiceKey("OrderID")]
  30:      public partial class Order
  31:      {
  32:      }
  33:      /// <summary>
  34:      /// OrderDetail Class Data Service Key Fix
  35:      /// </summary>
  36:      [DataServiceKey(new string[]{"OrderID","ProductID"})]
  37:      public partial class OrderDetail
  38:      {
  39:      }
  40:      /// <summary>
  41:      /// Product Class Data Service Key Fix
  42:      /// </summary>
  43:      [DataServiceKey("ProductID")]
  44:      public partial class Product
  45:      {
  46:      }
  47:      /// <summary>
  48:      /// Region Class Data Service Key Fix
  49:      /// </summary>
  50:      [DataServiceKey("RegionID")]
  51:      public partial class Region
  52:      {
  53:      }
  54:      /// <summary>
  55:      /// Shipper Class Data Service Key Fix
  56:      /// </summary>
  57:      [DataServiceKey("ShipperID")]
  58:      public partial class Shipper
  59:      {
  60:      }
  61:      /// <summary>
  62:      /// Supplier Class Data Service Key Fix
  63:      /// </summary>
  64:      [DataServiceKey("SupplierID")]
  65:      public partial class Supplier
  66:      {
  67:      }
  68:      /// <summary>
  69:      /// Territory Class Data Service Key Fix
  70:      /// </summary>
  71:      [DataServiceKey("TerritoryID")]
  72:      public partial class Territory
  73:      {
  74:      }
  75:  }

This will enable you to use Astoria with OpenAccess for all of the tables in your database. I converted my Tech*Ed “Data Access Hacks and Shortcuts” session demo to use OpenAccess and Astoria from the Entity Framework in less than 5 minutes. (I will show it and give away the code on my blog in a week or two.)

image

Enjoy!

Technorati Tags: ,
posted on Saturday, January 23, 2010 6:24:52 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Thursday, January 21, 2010

I will be presenting a half day seminar on Agile Development, Tools and Teams on Wednesday February 24th at the MCCIA in Pune. The event is brought to you free by e-Zest, MCCIA, and Telerik. Seats are limited, to sign up in advance, please email seminar@e-zest.net.

The Program Details

One of the most popular Agile project management and development methods, Scrum is starting to be adopted at major corporations and on very large projects. After an introduction to the basics of Scrum like: project planning and estimation, the Scrum Master, team, product owner and burn down, and of course the daily Scrum, Stephen (a certified Scrum Master) shows many real world applications of the methodology drawn from his own experience as a Scrum Master. Negotiating with the business, estimation and team dynamics are all discussed as well as how to use Scrum in small organizations, large enterprise environments and consulting environments. Stephen will also discuss using Scrum with virtual teams and an off-shoring environment. We’ll then take a look at the tools we will use for Agile development, including planning poker, unit testing, and much more. There will be plenty of time for Question and Answer. This seminar is a jump start for a certified scrum master exam. 

Who Should Attend 

Developers and development managers, especially those using the Microsoft .NET platform. 


Schedule and Agenda

Seminar Coverage

Time Slot

Event Registration

9:00-9:55

Speaker Introduction

9:55-10:00

Introduction to Agile Development and Scrum

10:00-11:00

Agile Estimation

11:00-11:30

High Tea Break

11:30-11:45

Implementing Scrum with remote and offshore teams

11:45-12:15

Agile Tools, Test Driven Development, and Continuous Integration

12:15-12:45

Summary, Question and Answer

12:45-1:00

Conclusion of Program

1:00

 

The Speaker

Stephen Forte is the Chief Strategy Officer of Telerik, a leading vendor in .NET components. He sits on the board of several start-ups including Triton Works and is also a certified scrum master. Prior he was the Chief Technology Officer (CTO) and co-founder of Corzen, Inc, a New York based provider of online market research data for Wall Street Firms. Corzen was acquired by Wanted Technologies (TXV: WAN) in 2007. Stephen is also the Microsoft Regional Director for the NY Metro region and speaks regularly at industry conferences around the world. He has written several books on application and database development including Programming SQL Server 2008 (MS Press). Prior to Corzen, Stephen served as the CTO of Zagat Survey in New York City and also was co-founder of the New York based software consulting firm The Aurora Development Group. He currently is an MVP, INETA speaker and is the co-moderator and founder of the NYC .NET Developer User Group. Stephen has an MBA from the City University of New York. Stephen currently lives in Hong Kong and will be returning to Mt. Everest again in September 2010. 

Final Details

DATE

Wednesday February 24th, 2010

TIMING

9.00 am to 1.00 pm (registration from 9.00 a.m. to 9.45 a.m.)

VENUE

Shekhar Natu Hall, MCCIA, 403-A,Senapati Bapat Road, Pune 411 016

FEE

Free

 

Technorati Tags: ,
posted on Thursday, January 21, 2010 1:59:34 AM (Eastern Standard Time, UTC-05:00)  #    Comments [1] Trackback
# Wednesday, January 20, 2010

Telerik is proud to announce that the Data Services Wizard beta was released today. If you have used the wizard while it was a Telerik Labs project, you will notice a ton of new features and improvements. If you are new to the wizard, now may be a good time to give it a try and give us your feedback.

The Data Service Wizard works with Telerik OpenAccess Q3 or higher and Visual Studio 2008. Our next beta, due in February, will support Visual Studio 2010 and WCF 4.0. The wizard will create a service layer for you using “Astoria” 1.0, the latest version of “Astoria”, WCF, or the WCF REST or AtomPub project templates. You can get a walk through here.

To highlight some of the new features, I will give you some screen shots below.

First we made the navigation and project selection much easier. Now you can select your data access layer and your service project in one simple screen.

image

You asked for it, we delivered it: we are proud to announce Visual Basic .NET support!

image

We have also made the code preview page page optional.  As you can see we generate VB code. :)

image

Here is the completed Astoria service:

image

We’ll post some more how to and videos soon.

Enjoy!

Technorati Tags:
posted on Wednesday, January 20, 2010 4:03:36 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Tuesday, January 19, 2010

Telerik has been named to the Red Herring Global 100 Award list.  The Global 100 is Red Herring’s list of the top 100 privately held global tech companies. This is like the Fortune 500 list but for tech. This is a huge deal, past award winners include Google, Yahoo!, Skype, Netscape, Salesforce.com, and YouTube.

Telerik is an Eastern European company with headquarters in Sofia, Bulgaria and the only company on the Red Herring Global 100 from the former “Soviet Block.” That the company's founders grew up under communism and last week were speaking at the Red Herring 100 award ceremony about capitalism, innovation, and technology is totally awesome. Shows you how technology can empower people and change the world.

It is quite an honor to work at a company in the Red Herring Global 100.

image

According to the Red Herring web site, the selection process is:

A group of Red Herring editorial judges will review each nomination. The editors will assess nominees on both quantitative and qualitative criteria such as financial performance, technology innovation, quality of management, execution of strategy, and integration into their ecosystem. Specific to the Red Herring 100 Global Award, the judges will look closely at the company's global strategy to evaluate how the company will be able to handle the challenges of internationalization and a global presence.

Technorati Tags:
posted on Tuesday, January 19, 2010 5:32:14 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Thursday, January 07, 2010

As you may know Telerik has built into most of its products support for Windows and SQL Azure. While at the PDC last November, Ben Riga interviewed me on what it was like to build a commercial product on top of Azure. I give a sneak peak at how we developed the software and how we leveraged SQL Azure. I talk about some of our pain points as well as where it was easy. The video is here, complete with my cell phone’s battery dying in the middle of our interview!

Get Microsoft Silverlight

Enjoy!

Technorati Tags: ,
posted on Thursday, January 07, 2010 3:31:11 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Sunday, December 27, 2009

Here is a special holiday message from Telerik!

PS: I did not make the video cutoff due to travel delays from Hong Kong to the snowstorm on the East Coast.

Enjoy!

posted on Sunday, December 27, 2009 9:26:59 PM (Eastern Standard Time, UTC-05:00)  #    Comments [1] Trackback
# Friday, December 18, 2009

The Astoria (aka ADO.NET Data Services) team released an updated .NET 3.5 SP1 version of Astoria the other day. There are tons of great new features like projections and my favorite, an inline row count. As I said on my blog yesterday, you have to alert Astoria that you want to use the new V2 features, by default Astoria 2.0 runs in Astoria 1.0 mode. (For backwards compatibility.)

Telerik has enhanced the Data Services Wizard to support Astoria 2.0 (officially the “Data Services update for .NET 3.5 SP1” but I digress….)

Now if you have the updated Data Services DLLs on your machine, you will have the option to create a service using V1 or V2. If you choose V2, we will automatically set the MaxProtocolVersion property to V2 for you.

12-17-2009 5-38-01 PM

Happy Data Servicing!

Technorati Tags: ,
posted on Friday, December 18, 2009 5:41:52 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Thursday, December 17, 2009

The Astoria (aka ADO.NET Data Services) team released an updated .NET 3.5 SP1 version of Astoria last night. This version of Astoria is an inplace update and will overwrite your current version of Astoria (System.Data.Services.*.dll). You can download it from the following locations.

The new version of Astoria has some very useful and powerful features. They include projections, data binding, row count, feed customization, server based paging and better BLOB support. There is one small issue, in order to support these new features you have to tell the framework you are using the new version of Astoria. For backward compatibility reasons, by default Astoria will work in “1.0” mode and none of the new features will work out of the box. To take advantage of the 2.0 features, you have to make two minor changes to the InitializeService method:

   1:  //change the IDataServiceConfiguration to DataServiceConfiguration
   2:  public static void InitializeService(DataServiceConfiguration config)
   3:  {
   4:      config.SetEntitySetAccessRule("*", EntitySetRights.All);
   5:      //take advantage of the "2.0" features
   6:      config.DataServiceBehavior.MaxProtocolVersion =
   7:          System.Data.Services.Common.DataServiceProtocolVersion.V2;
   8:  }

The first thing that you need to change is on line 2, change the interface IDataServiceConfiguration to be just DataServiceConfiguration (I am sure that there is a better way to do this, I have not figured it out yet.). Next, set the MaxProtocolVersion property of DataServiceBehavior to V2. After that you can take advantage of all the new features!

I want to take advantage of my favorite new feature, the inline row count. (I have been asking over and over for this feature, so: Thanks Astoria team!!!) The inline row count will return the number rows in the data feed regardless of paging ($skip, $top etc) as an XML element: <m:count>. This new property makes our RAD Grid and other paging aware controls much easier to perform paging. To make this work, you just add the inlinecount to the querystring:

servicename/entityname?$inlinecount=allpages
 

Let’s implement this with the example I did the other day using Telerik OpenAccess and the Data Service Wizard. If you remembered I built a simple Astoria 1.0 service exposing the Customers entity. We built this using “Astoria 1.0”, however, I upgraded my machine with the release of Astoria 2.0. When I use inlinecount, I get a 404 error. As with a brand new service, we have to tell the framework what version of Astoria we want to use before we can take advantage of inlinecount. I made the same changes as I did above (DataServiceConfiguration and MaxProtocolVersion ) and reran my application. Now when I type this URL: http://localhost:1191/WebDataService.svc/Customers?$inlinecount=allpages&$top=2

I get only the top two records but the total count of records.

image

Awesome.

Enjoy Astoria 2.0!

PS:

I thought that this was called “WCF Data Services”? According to the Astoria team blog:

Since this release is an update to the .NET Framework 3.5 SP1 we kept the name consistent with what was used in the 3.5 SP1 timeframe so that printed documentation, etc is consistent.  Going forward in .NET 4 and onwards you’ll see us use WCF Data Services.

Technorati Tags:
posted on Thursday, December 17, 2009 3:51:54 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Tuesday, December 15, 2009

Last week Telerik released the December CTP of the Data Services Wizard. I posted on my blog a video that shows how to get started, however, for those of you that like walkthroughs better, here is one using a WCF Data Services (Astoria) service.

Getting Started: Mapping Data With OpenAccess

To get started, first download and install the Data Services Wizard. After that, fire up Visual Studio and create a new Class library application named Telerik.DSW.Demo.Astoria.DAL. Run the OpenAccess “Enable Project to use ORM” wizard and then run the Reverse Mapping Wizard and map to your database. For this demo I mapped the Northwind database.

Map as many tables as you like, you can also manually remove the complex properties (Customer Collection from the Order entity for example) via the mapping wizard if you want to use that entity in your service. (Don’t worry we will have a solution for this when we have our January beta!)

Note: your wizard may not have created the ObjectScopeProvider in your DAL project. If you don’t have one in your DAL project via the main menu choose Telerik|Open Access|Configuration|Connection Strings. Then select the ObjectScopeProvider check box showed in the dialog below and click on ok.

image

Next Up: Using the Wizard

The WCF Data Service that the wizard will create has to reside in another (Web) project. So let’s create a Web project named Telerik.DSW.Demo.Astoria.Web.

image

Now it is time to start the wizard. Just select from the main menu Telerik|Data Services Wizard.

image

This will bring up the first page of the wizard, Select DAL Project. Here you select the name of the project that has your OpenAccess entities. Select the DAL project and click Next.

image

The Select Data Service screen is where you have to enter in some important information.

First put in the namespace, this is the namespace of your web project. (Future versions of the wizard will default to this namespace), and the name of your service, I choose Northwind as my creative service name. Also select which entities to generate as part of your service. I choose Customer, Order, and OrderDetail. Lastly, select which type of Service to create, in this case a WCF Data Service (our wizard did not catch up with the name, so you have to select ADO.NET Data Service (Astoria).)

image 

After you click next, you can preview the generated code on the View Output screen.

image

Click next and then you will be asked to choose which project to add the service to on the Finish screen. Select the web project, or Telerik.DSW.Demo.Astoria.Web and click next.

image

Now the wizard does a lot of work for you.

First it sets a reference to all of the WCF Data Services libraries (System.Data.Services and System.Data.Services.Client.) Next it sets a reference to the DAL project for you (in our case Telerik.DSW.Demo.Astoria.DAL) and also sets a reference to the Telerik OpenAccess DLLs for you (Telerik.OpenAccess and Telerik.OpenAccess.Query.) Lastly, the wizard created the Northwind.cs OpenAccess reference file as well as the actual data service (svc and cs) files.

image

The last step is to run the service. Just right click on the SVC file and choose View in Browser from the context menu. You will see your RESTful service come up in the browser. From here you can set up a client to consume the service in ASP.net, Silverlight, or any other Microsoft and non-Microsoft technology.

image

Enjoy!

Technorati Tags:
posted on Tuesday, December 15, 2009 5:06:18 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Thursday, December 10, 2009

This week we released our third “alpha” CTP build of our Telerik OpenAccess Data Services Wizard on Telerik Labs. We have received tons of feedback on the tool and look forward to more feedback. The wizard’s development team and the entire OpenAccess team have come up with a roadmap and would like some feedback from the community on it. In the spirit of a transparent design, I am going to publish the entire roadmap here for community review. Of course all of this can change blah blah blah. (The lawyers made me say that.)

Beta 1: January 2010

  • Using T4 Code generation instead of text templates
  • VB.NET code generation (we had a ton of requests for this one!) 
  • Add WCF Data Services 1.5 full integration using the new Data Service Provider (of course we need to make changes to OpenAccess core to implement the DSP, however, the DSP is currently not fully documented by Microsoft, so we don’t know how much work this is just yet.)
  • Generate only the primitive types and prevent generation of complex entities for all services. (WCF barfs on complex types and entities.)

Beta 2: February 2010

  • Full support for WCF RIA Services
  • Full support for Azure Services
  • If you use the wizard to build a service, give you the option to automatically create a Silverlight client along with some code generation to consume the service to get you started
  • ASP.NET Dynamic Data support

Release: Telerik Q1 2010 Release

  • Full integration with OpenAccess’ installer. No longer making the wizard a separate install, it will just install as part of OpenAccess
  • Use of OpenAccess internal APIs
  • Visual Studio 2010 support
  • WCF 4.0 Support. We currently require the WCF 3.5 REST Starter Kit for two of our output modes: REST Collection and AtomPub. .NET 4.0 mode will eliminate this dependency and give you the option to produce WCF 4.0 REST services, etc.

After the Q1 release the roadmap is not super clear. I will assume that core development will slow down a little and that we will then focus mostly on adding support for new service types. I am sure that by next spring, there will already be some new service types to support like the release build of WCF RIA Services, maybe a new CTP of Astoria, etc.

Drop me a line and let me know what you think! Also, the tech support team is adding a separate Data Service Wizard forum in the Telerik support forums, so even though the wizard is technically a “lab” project and not supported, drop by and ping the team with your questions there. We’ll answer all your support questions there as well.

Enjoy and thanks for any feedback you send.

Technorati Tags: ,
posted on Thursday, December 10, 2009 8:10:33 AM (Eastern Standard Time, UTC-05:00)  #    Comments [1] Trackback
# Wednesday, December 09, 2009

Telerik released the December CTP of the Data Services Wizard earlier this week. Here is a video by .NET Ninja in training Peter Bahaa on using the wizard:

Telerik OpenAccess Data Services Wizard December CTP from Stephen Forte on Vimeo.

Technorati Tags: ,
posted on Wednesday, December 09, 2009 10:33:31 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Monday, December 07, 2009

We are proud to announce our December CTP of the Telerik OpenAccess Data Services Wizard (formerly known as the WCF Services Wizard). The Data Services Wizard (DSW) allows you to easily create a CRUD data service layer for your application. The DSW does this by using a data access layer already built by OpenAccess and automatically generating the C# code for your endpoints. The types of endpoints you can create are:

  • WCF Data Services (FKA Astoria and also FKA ADO. NET Data Services)
  • Raw WCF endpoints
  • WCF REST Collection endpoints
  • WCF ATOMPub endpoints

This version of the Data Service Wizard is very robust; we have made lots of changes based on your feedback. Our #1 piece of feedback from customers has been to integrate the DSW with OpenAccess and Visual Studio. I am proud to announce that in this version the DSW is fully integrated with Visual Studio!

We have also started to integrate the DSW into the OpenAccess product itself. No longer is the DSW a standalone product; the wizard is now  located under the “Telerik” menu in Visual Studio and looks like the other OpenAccess wizards. Integration will get tighter in the near future and soon just be part of OpenAccess proper, not a separate download.

The basics of the wizard are the same. The DSW will ask you which project your OpenAccess entities are located in and then which entities you will expose in your endpoint.

ScreenShot1

After you choose the entities you want to expose and what type of service you want to build (WCF, Astoria, etc), you can preview the code that is generated.

ScreenShot2

A major improvement with the December CTP is that you can now automatically insert these service endpoint files into a project, eliminating the manual step of copying them on over. This will make building the services so much easier!

image011

Go grab the wizard here. It is still considered a Telerik Labs project, but we will move it to a fully supported beta in January with our next build. On the dock for the next build (early January) are:

  1. Using T4 Code generation instead of text templates
  2. VB.NET code generation
  3. Add WCF Data Services 1.5 full integration (using the new Data Service Provider)
  4. Prevent the generation of complex entities for all services

Future versions of the product will be fully part of OpenAccess and will also support RIA Services, Azure Services, and Visual Studio 2010 and WCF 4.0. Download today and send us feedback!

posted on Monday, December 07, 2009 9:39:31 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Wednesday, December 02, 2009

Yesterday I showed how to use Telerik OpenAccess, Telerik Reporting, and SQL Azure to create reports and view them in ASP.NET. Today i will show how to view that same report in Silverlight using the industry’s first native Silverlight report viewer. All of this is in the Telerik documentation, however, since we have our cool SQL Azure demo already up and running from yesterday, I figured it would be fun to show how to reuse the same report and view it in Silverlight.

Getting Started

Remember from yesterday that we have three projects in our solution:

  • Telerik.Reporting.DAL-the class library project containing our OpenAccess entities (mapped back to SQL Azure tables)
  • Telerik.Reporting.RptLib-the class library project containing our Telerik report using the DAL project as a data source
  • Telerik.Reporting.Web-the ASP.NET application containing our Report Viewer control, allowing the users to view the report

Now we will add a Silverlight project named Telerik.Reporting.SL that will use the Telerik.Reporting.Web application as its ASP.NET host.

image

The Telerik Reporting WCF Service

Since all data access in Silverlight has to be an asynchronous service, we have to send our report down to our Silverlight application as a WCF service. At the end of the day a Telerik Report is just a plain old .NET class, so we can easily send it down via WCF. The good news is that a lot of the WCF plumbing has been taken care of for you by the Telerik Reporting service. Let’s get started.

First we have to set a reference in our ASP.NET host application (Telerik.Reporting.Web) to Telerik.Reporting.Service. Next add a WCF service to your project, named ReportService.svc. This will also automatically add a reference to System.ServiceModel for you.

Now delete everything in the SVC file and replace it with this:

<%@ServiceHost Service="Telerik.Reporting.Service.ReportService, Telerik.Reporting.Service, 
Version=3.2.9.1113, Culture=neutral, PublicKeyToken=A9D7983DFCC261BE" %>

Note: you have to make sure that the version number you are using is the same as mine. You can get your version number by clicking on the Telerik.Reporting.Service reference in the solution explorer and looking at the version property.

image

Next you will have to add the WCF endpoint to the configuration section of the web.config of the same ASP.NET project that has the ReportService.svc WCF service. (You can copy this code to paste as is into your application from the Report Service support page.)

 
 <system.serviceModel>
   <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
   <services>
     <service name="Telerik.Reporting.Service.ReportService" 
        behaviorConfiguration="ReportServiceBehavior">
      <endpoint address="" binding="basicHttpBinding"
        contract="Telerik.Reporting.Service.IReportService">
         <identity>
           <dns value="localhost" />
         </identity>
       </endpoint>
       <endpoint address="resources" 
          binding="webHttpBinding"
          behaviorConfiguration="WebBehavior" 
          contract="Telerik.Reporting.Service.IResourceService"/>
       <endpoint address="mex" binding="mexHttpBinding" 
          contract="IMetadataExchange" />
     </service>
   </services>
   <behaviors>
     <serviceBehaviors>
       <behavior name="ReportServiceBehavior">
         <serviceMetadata httpGetEnabled="true" />
         <serviceDebug includeExceptionDetailInFaults="false" />
       </behavior>
     </serviceBehaviors>
     <endpointBehaviors>
       <behavior name="WebBehavior">
         <webHttp />
       </behavior>
     </endpointBehaviors>
   </behaviors>
 </system.serviceModel>

 

That is it for the Telerik WCF Reporting Service. Now let’s add a ReportViewer to our Silverlight application.

Using the Telerik Silverlight Report Viewer Control

The Telerik Silverlight Report Viewer offers native report viewing support for Silverlight. It uses the same rendering engine and offers the same functionalities as the other Telerik viewers, so your report will render the same in Silverlight as in Windows Forms as ASP.NET. To get started, you need to add a reference to the Telerik Silverlight controls in your Telerik.Reporting.SL project:

  • Telerik.Windows.Controls.dll
  • Telerik.Windows.Controls.Input.dll
  • Telerik.Windows.Controls.Navigation.dll

These controls are located in the following folder:

Program Files\Telerik\RadControls for Silverlight Q3 2009\Binaries\Silverlight\

In addition, you need to add a reference to the ReportViewer:

  • Telerik.ReportViewer.Silverlight.dll

This library is located in Program Files\Telerik\Reporting Q3 2009\Bin\

Lastly, add a reference to our report project: Telerik. Report.RptLib.

Now you can add the report viewer namespace and control to your XAML:

   1:  <UserControl
   2:      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
   3:      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   4:      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
   5:      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
   6:      mc:Ignorable="d" 
   7:      xmlns:Telerik_ReportViewer_Silverlight=
   8:       "clr-namespace:Telerik.ReportViewer.Silverlight;
   9:        assembly=Telerik.ReportViewer.Silverlight" 
  10:      x:Class="Telerik.Reporting.SL.MainPage"
  11:      d:DesignWidth="640" 
  12:      d:DesignHeight="480">
  13:    <Grid x:Name="LayoutRoot">
  14:        <Telerik_ReportViewer_Silverlight:ReportViewer 
  15:          Margin="0,0,20,8" 
  16:          ReportServerUri="../ReportService.svc" 
  17:          Report="Telerik.Reporting.RptLib.CustomerRpt, 
  18:              Telerik.Reporting.RptLib, Version=1.0.0.0, 
  19:              Culture=neutral, 
  20:              PublicKeyToken=null"/>                                                  
  21:    </Grid>
  22:  </UserControl>

 

Note: The Telerik support page for the Silverlight Report Viewer is a good reference for the code needed and you can copy and paste from there instead of from here. Alternatively, you can use Expression Blend to add the report to your XAML form and you don’t have to worry about the namespaces and XAML for the ReportViewer, Blend will take care of that for you, all you have to worry about are the ReportServiceUri and Report properties. If you are not using Blend, just make sure that the properties are in the correct order in the XAML (ReportServiceUri first, Report second) or you will get some nutty bugs. (Ask me how I know this!)

You are going to have to set two properties of the ReportViewer control (either manually in XAML or in Blend):


  • ReportServiceUri: or the absolute or relative path back to the WCF service in the ASP.NET solution
  • Report: or the assembly qualified name of your report class

<Sidebar>

How to find the assembly qualified name of your report? I was confused at first too. There are some PowerShell tools, etc, but I am PowerShell challenged. Instead, just add a label to an ASP.NET WebForm in the Telerik.Reporting.Web project and on the page load event add this code:

   1:  Type ty = typeof(Telerik.Reporting.RptLib.CustomerRpt);
   2:  Label1.Text = ty.AssemblyQualifiedName;

Then run the page in the browser and copy and paste the fully qualified assembly name into your XAML as I did. :)

</Sidebar>

That is it. Next step is to set your Slverlight test page as startup and F5. The ReportViewer supports native printing and export capabilities to PDF, XLS, Excel, etc. Pretty cool.

image

Enjoy!

Technorati Tags:
posted on Wednesday, December 02, 2009 7:20:54 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Tuesday, December 01, 2009

Telerik Reporting is a great reporting package. If you using it, you may be happy to know that you can use Telerik OpenAccess as a data source. Let’s take a look at how to use it with a SQL Azure Database as a back end.

Getting Started

First you need to map your SQL Azure tables to OpenAccess entities. I demonstrated this before on my blog, if you have not used OpenAccess and SQL Azure yet, read this post. (Don’t worry I’ll wait.) What I did for this demo is create a library project called Telerik.Reporting.DAL and mapped all of the Northwind tables in my SQL Azure database to OpenAccess entities in a class library.

Next I created another library project to contain the reports called Telerik.Reporting.RptLib. This solution will contain all of your reports. It is good to create all of the reports inside one isolated solution so you can reuse these reports in an ASP.NET solution as well as other projects like Silverlight. After we created this project, I ran the OpenAccess enable project wizard to get all of the proper references set up to use OpenAccess. In addition, I set a reference to our Telerik.Reporting.DAL project so we can see the entities we just mapped.

Creating a Report

Now it is time to create a report. Just right click on the project and select Add| New Item and choose the Telerik Report Q3 2009 template from the Reporting category.

image

The Telerik Reporting Wizard will come up. Select the option to build a new report and a new data source. For a data source type, select Business Object from the options available.

image

Next drill down into the Telerik.Reporting.DAL namespace and then select the Customer entity.

image

The next few pages of the wizard ask you how to lay out your report and what data fields to choose from. The wizard is self explanatory, so I will not go into detail here, but just choose any style that you like and show some customer fields on the report. I choose to show Customer ID and Company Name in standard report. My report looks pretty basic in design view:

image

 

Wiring up the data

We are almost there. Next step is to write a little LINQ code behind your report to wire up the OpenAcces data source with your report. Right click on the design canvas of the report and select “View Code.” That will take you to the code behind. Create a function like the one below that uses the OpenAccess LINQ implementation and return all of the customers (We could more complex LINQ queries here if we wanted to. )

   1:  public static List<Customer> GetCustomers()
   2:  {
   3:      //LINQ Query to fetch all of the Customers via OpenAccess            
   4:      //data context (IObjectScope)
   5:      IObjectScope dat = ObjectScopeProvider1.GetNewObjectScope();
   6:      //Get a ILIst of Customers
   7:      List<Customer> result = (from c in dat.Extent<Customer>() select c).ToList();
   8:      return result;
   9:  }

The function above returns a List of Customers. The IObjectScope in line 5 is the data context and the LINQ statement is in line 7.

But we have one problem. While we set all of the proper references, we are missing a bunch of using statements. You can manually add them here:

   1:  using System.Collections.Generic;
   2:  using System.Data;
   3:  using System.Linq;
   4:  using Telerik.OpenAccess;
   5:  using Telerik.Reporting.DAL;

 

Or you can use the new Telerik JustCode tool to organize and fix your using statements:

image

You need to add one more line of code to your report. Add the following to the report’s construtctor, it will wire up your function as the data source of the report:

   1:  DataSource = GetCustomers();

The ReportViewer Control

Now it is time to view the report. To do that create a new ASP.NET application called Telerik.Reporting.Web. Set a reference to the Telerik.Reporting.RptLib project where the report you just created is located. After that drag a Telerik ReportViewer control from your palate to the ASP.NET web form.

image

All you need to do now is add one line of code to the page load event (or a button click event, etc) to load the CustomerRpt we just built into the ReportViewer.

   1:  if (!IsPostBack) { ReportViewer1.Report = new CustomerRpt(); }

Next step is to run it and see your report in action!

image

Enjoy!

Technorati Tags:
posted on Tuesday, December 01, 2009 9:24:03 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Monday, November 23, 2009

Last week at PDC, Telerik launched a new product named JustCode. It was a stunning success since we had a lot of people show up for the launch and we gave away 1,000 free licenses at the event. Back in March at a planning meeting at Telerik HQ, we decided that we would embark on an Apple style “secret” strategy and go for the most buzz at launch.

Back at that meeting in March we decided that secrecy, which goes against a lot of our values at Telerik, would be required for the most buzz at the launch. But keeping a secret is not easy in the world of Twitter, blogs, and Facebook. Back in March only the development team, their closest buddies, and the senior management knew about JustCode. But that had to change soon as we started to dogfood JustCode a month or so later at Telerik. We were certain if we communicated the goal of being secret that there would not be any leaks. At the same time we decided to extend JustCode outside Telerik to a handful of vendors (super thanks to Imaginets for not only building the Work Item Manager and Dashboard, but doing it with clunky pre-alphas of JustCode.) A little later on, we also gave a super early look to the Telerik MVPs and DevReach speakers. Nobody let the news out.

Nobody that is, except me- one of the architects of the “secret” plan.

The fist boo-boo I made was mention it to a fellow Telerik employee back in March just after that meeting. Oops, but no big deal, it was at least in the family.

The next snafu was in Durban, South Africa, back in August. I was speaking at TechEd South Africa and I used my non-presenter VPC to do one of my demos since that had the particular Silverlight 3.0 bits on it and my presentation VPC had only Silverlight 2.0 (long story but a different demo needed SL 2.0 at the time. Remember SL 3.0 only shipped the week before..) My non demo VPC of course had JustCode early alpha on it since we were dogfooding it at Telerik. Most of you know me and know that I love to write a lot of code in my sessions. Well I had to do some refactoring in one of my talks and boom, without thinking, used JustCode on stage. Big oops! Luckily the handful of folks who came up to me after to ask “do you have a super fast beta of Resharper on your machine?” were sworn to secrecy and kept their word of the secrecy of JustCode. (The free license I promised them also didn’t hurt.)

Next came the awesome video product teaser that generated a lot of buzz. If you didn’t see it, watch it here.

Next came Basta in Germany in September. Our marketing team printed up flyers with all of our products on it. Somehow JustCode made it to the flyer! After a few frantic calls back and forth, the team at Basta decided that we would test the waters and give the flyers out. The first person who noticed it asked if we support F#. Everyone who came to the booth was sworn to secrecy.  After Basta the flyers were destroyed. (Look for a few of them on eBay, they are now a collector’s item.)

Lastly was the day of the launch. I was wearing a JustCode tee shirt well before the launch. I was filming an MSDN video and also speaking at my BOF talk, so Stefan decided to put tape over the “Code” on my tee shirt to generate some buzz. It worked but I took the tape off and put it back on about an hour before the launch to reposition the tape for the unveiling, and the C and E were now showing, so people were able to guess.

Despite my attempts to sabotage our well laid plans, the launch went great. Note to Telerik: next time don’t tell me the secret product launch!

Technorati Tags: ,
posted on Monday, November 23, 2009 3:22:34 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Wednesday, November 18, 2009

PDC is well underway and of course Telerik launched JustCode last night. It was fun walking around with the JustCode tee shirt on all day and duck tape over the CODE part.

If you are at the PDC swing by the Microsoft SQL Server booth and take a look at two of our exciting new projects. Microsoft is highlighting both our OpenAccess Data Services Wizard and our LINQ to M implementation.

See you at the Telerik booth, my sessions, or a party. :)

image

Technorati Tags: ,
posted on Wednesday, November 18, 2009 9:38:03 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Monday, November 16, 2009

Joel and I are doing a BOF session on Tuesday about Agile tools and Teams. (I am not listed on the PDC web site for some reason, but I will be there alongside Joel.)

We will most definitely show the Telerik Dashboard and Work Item Manager as well as chat about tons of other great tools. Most importantly, we want to hear from you at this session. We did it that way at TechEd in LA earlier this year (the #1 ranked interactive session at TechEd 2009) and it worked well. Hope to see you there and have a great discussion.

Tooling on Agile Teams

Joel Semeniuk in 309 on Tuesday at 3:00 PM

Agile practices focus on customer value and team interactions. There is significantly growing and important set of tools that work to help Agile teams be more “agile”. In this session, we would like to hear what you have to say about tools for Agile teams? What tools work? What tools don’t work? What tools are missing in the industry? What tools can you not live without? Come join the discussion or simply listen to what your peers have to say.

See you there!

image

posted on Monday, November 16, 2009 1:54:14 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Thursday, November 12, 2009

Just a few weeks ago Microsoft released Visual Studio 2010 Beta2. Last week Telerik put its Q3 release live into production. One of the cool new Q3 features is that OpenAccess now works seamlessly with Visual Studio 2010. That means you can target .NET 3.5 or .NET 4.0 using either Visual Studio 2008 (.NET 3.5) or Visual Studio 2010 (.NET 4.0).

I will do a quick demo with Visual Studio 2010, SQL Azure, and OpenAccess. With OpenAccess Q3 installed, I fired up Visual Studio 2010 and started a console project targeting .NET 4.0

image

While the project will target the .NET 4.0 Framework, we have to do one small thing to make it work. By default the project type is “.NET 4.0 Client Profile” so we have to change that to a straight up .NET 4.0 project type. The way to do this is to right click on the project and select properties. In the properties dialog Application section, you will see Target framework;  select .NET 4.0 and you are good to go. (Visual Studio will have to close and reopen the project for you.)

image

Next we have to fire up OpenAccess via the Enable Project Wizard. When I start the Enable Project to use ORM Wizard, OpenAccess asked me what database to use, and as I showed before on this blog, Q3 now supports SQL Azure natively. Notice that the wizard will prompt you to put in your SQL Azure credentials and will give you the basic template for your server name: tcp:<sqlazureid>.database.windows.net.

image

Note: Depending on your setup in Visual Studio 2010, you may have to use the Server name without the tcp: and use the syntax UserName@sqlazureid. Visual Studio 2010 will give you an error in your setup if the default does not work. If you get this error you would enter the following for your SQL Azure credentials:

Server Name: sqlazureid.database.net (no tcp:, so for example p28drog84.database.net)
User Name: YourSQLAzureUserID@sqlazureid (for example: Stevef@p28drog84)

Next you will want to map some SQL Azure tables to OpenAccess entities. This can be done pretty easily, just by running the Reverse Mapping wizard. Here you can select your tables to map. By default OpenAccess will also now map the foreign keys of each entity as a primitive type in addition to the complex type. This will help a great amount if you are using your entities in conjunction with any data service such as WCF or ADO .NET Data Services. (More on that later.)

image

Once you have mapped your entities, you are free to work with them. You can use the OpenAccess LINQ implementation (which has went through a major overhaul and is in line with the LINQ to SQL and LINQ to Entities LINQ implementations.) As I showed last time, you can write a simple LINQ statement to filter all the Customers by a certain country as shown here:

   1:  static void Main(string[] args)
   2:  {
   3:      IObjectScope dat = ObjectScopeProvider1.GetNewObjectScope();
   4:      //LINQ Statement   
   5:      var result = from c in dat.Extent<Customer>()
   6:                   where c.Country == "Germany"
   7:                   orderby c.CompanyName
   8:                   select c;
   9:      //Print out the company name  
  10:      foreach (var cust in result)
  11:      {
  12:          Console.WriteLine("Company Name: " + cust.CompanyName);
  13:      }
  14:      //keep the console window open  
  15:      Console.Read();
  16:  }

 

image

Enjoy!

posted on Thursday, November 12, 2009 11:20:25 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Tuesday, November 10, 2009

Last summer Telerik released the Oslo Comparison and Migration Tool. It is a tool that is available free for the community. It allows you to compare two Microsoft code named “M” files, see a visual diff, and then merge the results. (M is the code name for a new data modeling language from Microsoft.)

Telerik has expanded the tool to allow comparison of items in the SQL Server “Repository” and then do the same visualdiff and them merge the schema. Developers who have been playing with the M language and repository will find it very useful to have a tool that will allow comparisons and migrations, since the requirements of our applications are always changing! :) Pretty cool.

Just a note: Telerik will be updating the tool as soon as Microsoft makes some “M” and SQL Server “Repository” related announcements next week at PDC. Stay tuned!

posted on Tuesday, November 10, 2009 1:34:25 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Saturday, November 07, 2009

Next week I will be speaking at one of my favorite events, TechEd Europe, this year held in Berlin. While Barcelona is still my favorite city in the world, I am glad that we are in Berlin this year, since Monday is the 20th anniversary of the Berlin Wall falling, and our world changing forever.

I will be speaking on:

I speak on Tuesday and Wednesday, and the event is SOLD OUT. I hope you were lucky enough to get a ticket. I’ll be hanging out at the Telerik booth when I am not speaking if you want to come and say hi.

image

Technorati Tags: ,
posted on Saturday, November 07, 2009 3:17:24 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Monday, November 02, 2009

Microsoft’s SQL Azure database offering has great 3rd party support. This week Telerik is releasing its Q3 version of its entire product line and the OpenAccess ORM will have more robust and native support for SQL Azure over what is currently available. I will expand on the example I did last week on connecting to SQL Azure by showing how to work with OpenAccess entities via WCF in a Silverlight application.

The fist thing that you have to do is create a project for your data access layer and connect to SQL Azure. I started a new class library and used the Enable Project to use ORM wizard. This is where you can specify your SQL Azure user account and credentials. I showed how to do this last week, so I will skip the steps here. (This is a new feature of Q3, in the previous version of OpenAccess, you had to use the SQL Server provider, now OpenAccess supports SQL Azure natively!)

Next we have to create a project to contain our WCF service. What we have to do next is point the Telerik Data Service Wizard to the DAL project and have it automatically create the SVC and CS files of our service for us.  The wizard will automatically create all of the CRUD methods for our entities. (In this demo I only used Customers.) In case you have not used the wizard yet, here is a walk through video on how to do that.

Telerik OpenAccess WCF Wizard Part I from Stephen Forte on Vimeo.

Now we will have two projects, one for our DAL and one for our WCF service. Now, add a Silverlight project and your solution should look like this, four projects: the DAL project, the WCF service project, the Silverlight Web project and the Silverlight project itself.

image

Next up we set a service reference to our WCF service and call the ReadCustomers method to get a list of all the customers and bind it to a XAML grid. (Remember that this being Silverlight, we have to do it all asynchronously.) We do this inside of a LoadData method in our form.

   1:  private void LoadData()
   2:  {
   3:      //ref to our service proxy
   4:      SampleWCFServiceClient wcf = new SampleWCFServiceClient();
   5:      //register the event handler-can move this up if you want
   6:      wcf.ReadCustomersCompleted += ReadCustomersCompleted;
   7:      //make an async call to ReadCustomer method of our WCF service
   8:      //get only the first 100 records (default)
   9:      wcf.ReadCustomersAsync(0, 100);
  10:  }

The first thing that we do in the code above is create a reference to our WCF service in line 4 and then register an event handler to catch the asynchronous completion of the event on line 6. On line 9 we make the (asynchronous) call to ReadCustomers(). Since ReadCustomers() will process asynchronously, we will have to go to the ReadCustomersCompleted() method to catch the event. Let’s look at that here:

   1:   
   2:  void ReadCustomersCompleted(object sender, 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:  }

In ReadCustomersCompleted we are doing seeing if a checkbox is checked and if so, we do some client side LINQ statements to filter on the client for only customers in Germany. (This is a holdover from a demo I did at BASTA in Germany, of course you should move your countries to a drop down list and then filter with a parameter! Better yet, filter via the WCF service on the server!) If the checkbox is not checked, we will just show all of the customers.

image

If you want to edit a customer (or add, etc), the Silverlight grid allows you to do this inside the grid itself. However, you have to make sure that all of your dirty records are recorded so you only send back the dirty records to your backend WCF service. (Why bother updating all of the records?)

Here is the code to build the collection on the Begin Edit of the grid. This code just adds the current customer object into our custom collection (editedCustomers) so we can loop through it later on if we are doing an update.

   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 that we have our collection of dirty customers, we have to deal with the save button. The code below is run when the user clicks on the save button, saving all dirty records. Line 6 sets up the WCF service via the proxy and line 8 registers the event. Lines 11-15 is a loop of all of the dirty customers. (I get them via the custom collection editedCustomers shown above.) Inside of the loop on line 14 we make the actual asynchronous call to the WCF service’s UpdateCustomer method passing in the object and its correct ID. While the UpdateCusotmerCompleted event will fire (since this method is called asynchronously) when the update is complete, we have nothing really in that method except some cleanup of our custom collection and a message box to the users that the update is complete.

   1:  void ButtonSave_Click(object sender, RoutedEventArgs e)
   2:  {
   3:      
   4:      //the WCF service
   5:      //ref to our service proxy
   6:      SampleWCFServiceClient client = new SampleWCFServiceClient();
   7:      //register the event handler-can move this up if you want
   8:      client.UpdateCustomerCompleted += UpdateCustomerCompleted;
   9:   
  10:      //save only the dirty customers
  11:      foreach (NorthwindWCFService.Customer customer in editedCustomers)
  12:      {
  13:          //call the WCF method async to update the customer
  14:          client.UpdateCustomerAsync(customer.CustomerID.ToString(), customer);
  15:      }
  16:   
  17:  }

That is all there is too it! An add or delete is done in the same way.

Enjoy!

Technorati Tags: ,,,
posted on Monday, November 02, 2009 5:13:59 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Friday, October 30, 2009

With the official release of SQL Azure less than three weeks away, we are starting to see mainstream vendor support for SQL Azure. Telerik’s OpenAccess ORM is no exception. With the Q3 release of OpenAccess next week, OpenAccess will have full support for SQL Azure, going further than the basic support available today that I demonstrated on my blog last month. Full wizard support, forward and reverse mapping, and of course data services support via the Telerik Data Services Wizard. Let’s take a look at the basics here.

Getting Started

To get up and running and show the mapping and LINQ support, I will open Visual Studio 2008 (or 2010) and create a simple Console Application named OpenAccess.Azure.Demo. The first step is to enable the project to use OpenAccess via the Enable Project Wizard. As part of the wizard you need to specify which database you are going to connect to. OpenAccess gives you many choices besides Microsoft SQL Server, and one of the native choices is Microsoft SQL Azure. After you select SQL Azure, you will need to provide your credentials (don’t forget to put the tcp: in front of your server name.)

image

After you connect and finish the wizard, it is time to do some mapping.

Mapping Database Objects

To map some database objects to persistent classes, choose the Reverse Mapping wizard. This will bring up the Reverse Mapping dialog where you can select which tables, views, and stored procedures you want to map. In this case I will just select all of the defaults and map all of Northwind (remember I migrated Northwind up to SQL Azure.) Now it is time to build a simple application.

image

Working with SQL Azure Data

Let’s write a LINQ statement to fetch all of the customers from one country and print it out to the console window. First tings first, you have to put in a using statement for OpenAccess:

using Telerik.OpenAccess;

Next we will create our LINQ statement. The LINQ statement will work like any LINQ statement in OpenAccess, there is nothing special for SQL Azure, this LINQ statement would work against SQL Server, MySQL, or Oracle.

   1:  static void Main(string[] args)
   2:  {
   3:      //data context
   4:      IObjectScope dat = ObjectScopeProvider1.GetNewObjectScope();
   5:      //LINQ Statement
   6:      var result = from c in dat.Extent<Customer>()
   7:                   where c.Country == "Germany"
   8:                   select c;
   9:      //Print out the company name
  10:      foreach (var cust in result)
  11:      {
  12:          Console.WriteLine("Company Name: " + cust.CompanyName);
  13:      }
  14:      //keep the console window open
  15:      Console.Read();
  16:  }

The LINQ statement uses the data context, or IObjectScope in line 4, has a simple LINQ statement on lines 6-8 to filter by the customers in Germany and then iterates those customers and prints them out to the console window in lines 10-13. The result is shown here:

image

Pretty basic application, however, you can see that Telerik OpenAccess has full support for SQL Azure. Next week I will show a more complete example.

Enjoy!

Technorati Tags: ,
posted on Friday, October 30, 2009 3:47:58 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Tuesday, October 27, 2009

The Telerik WCF Wizard that I have shown on this blog several times has been updated and is available on Telerik Labs for download.

Whenever Telerik puts something up on Telerik Labs we hope that some early adopters will try it out and give us feedback. We had an amazing demand for the Telerik OpenAccess WCF wizard and got tons of feedback. The most overwhelming piece of feedback is the name of the wizard: so as of this CTP, the wizard is now renamed the Telerik Data Services Wizard.

screen1

We made some key enhancements in this build for useability. The big thing is that you no longer have to be an ADMIN user to use the wizard. In addition, we made some of the navigation simpler as well as squashed some bugs (mostly around using LINQ statements in older versions of OpenAccess). Speaking of older versions of OpenAccess, the wizard will automatically detect what version of OpenAccess you have installed and auto-update itself to work with that version.

We’re working around the clock on a new build that will have Visual Studio integration and a new UI that is more consistent with the OpenAccess UI. A little further out, we will also include support for ADO.NET Data Services 1.5 CTP2 using the new “data service provider” interface available in Astoria 1.5. Once we are at that point, we will release this a full fledged beta with a target for the wizard to be part of OpenAccess proper by Q1 release next year at the latest.

Enjoy!

Technorati Tags: ,,,
posted on Tuesday, October 27, 2009 7:27:04 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Saturday, October 10, 2009

On Monday and Tuesday I will speaking at DevReach in Sofia, Bulgaria. I’ll be doing my Data Access Hacks and Shortcuts and RESTful applications with Microsoft Tools sessions as well as the Daily Scrum talk with Remi Caron.

Chris Sells is doing a keynote on Oslo and Central Europe DPE lead Luka Debeljak will be doing a keynote on Azure. Should be great. Hope to see you there.

image

posted on Saturday, October 10, 2009 6:24:12 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
# Wednesday, September 09, 2009

The following video shows how to use the 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 #4- AtomPub from Stephen Forte on Vimeo.

posted on Wednesday, September 09, 2009 2:11:36 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Tuesday, September 08, 2009

Feeds are part of what power Web 2.0. You can use RSS or ATOM to syndicate your content and allow readers to subscribe to your content. It is what powers Twitter, Facebook, as well as CNN and the New York Times. ATOM is a popular alternative to RSS. Just about every blog and “RSS” reader will support ATOM. When you are talking about ATOM, you actually are talking about two things: Atom Syndication Format, an XML language for feed definitions, and the Atom Publishing Protocol, a very simple HTTP protocol for creating and updating feed based content.

The WCF REST Starter Kit allows you to create services that will produce an ATOM feed or expose your data as a service via the ATOM Publishing Protocol. The WCF REST Starter Kit gives you a Visual Studio template to get your started.

You can use Telerik OpenAccess as a data source for the collections of your ATOMPub service. To do so you have to wire up some code in your svc file back to your OpenAccess entities. This can be accomplished by using the OpenAccess WCF Wizard.

Creating the ATOMPub Service and a Silverlight Front End

To get started, let’s create four projects in Visual Studio, one data access layer using OpenAccess, one AtomPub service project using the new WCF REST Toolkit Visual Studio template, and a Silverlight Web/Client.

image

Then you can use the Telerik OpenAccess WCF Wizard to automatically create the SVC and CS files for an ATOMPub service (the arrow above.) Once you have that and allow the project to talk to the DAL with a reference to that project, view the service in the browser for a reality check. You can do the format, similar to REST of: http:// server name / service name / resource name, for example:

http://localhost:54669/NorthwindAtomPubService.svc/Customers will return a list of all the customers and if you add an /CustomerID to the end of the URL like this: http://localhost:54669/NorthwindAtomPubService.svc/Customers/ALFKI then you will bring up one individual customer.

image

Now let’s consume this from a Silverlight application. Pretty easy stuff, but first we have to create a XAML grid:

<data:DataGrid x:Name="dataGridCustomers" 
               AutoGenerateColumns="False" ItemsSource="{Binding}">
    <data:DataGrid.Columns>
        <data:DataGridTextColumn 
            Binding="{Binding Path=CompanyName}" Header="Company Name">
        </data:DataGridTextColumn>
        <data:DataGridTextColumn 
            Binding="{Binding Path=ContactName}" Header="Contact Name">
       </data:DataGridTextColumn>
    </data:DataGrid.Columns>
</data:DataGrid>

After you build your XAML grid, let’s set a service reference to the AtomPub service and then start to write some code. Just like before, I will have a LoadData() method to fill the grid. Of course being Silverlight it has to be asynchronous. Here is the code.

   1:  private void LoadData()
   2:  {
   3:  //the URL of our ATOM Pub service
   4:  string uri = "http://localhost:54669/NorthwindAtomPubService.svc/Customers";
   5:  //set up the web request
   6:  HttpWebRequest request = HttpWebRequest.Create(
   7:      new Uri(uri)) as HttpWebRequest;
   8:  //HTTP GET (REST uses the standard HTTP requests)
   9:  request.Method = "GET";
  10:  //begin the async call in a code block
  11:  request.BeginGetResponse(ar =>
  12:      {
  13:          Dispatcher.BeginInvoke(() =>
  14:              {
  15:                  //catch the HTTPWebRequest
  16:                  HttpWebResponse response = 
  17:                      request.EndGetResponse(ar) as HttpWebResponse;
  18:                  //get the customers back
  19:                  var result = 
  20:                      Customer.GetCustomersFromAtom20Stream(response.GetResponseStream());
  21:   
  22:                  //stuff the customers into a LIST
  23:                  List<Customer> customers = new List<Customer>();
  24:   
  25:                  foreach (var customer in result)
  26:                  {
  27:                      customers.Add(customer);
  28:                  }
  29:                  //bind the LIST to the Silverlight DataGrid
  30:                  dataGridCustomers.DataContext = customers;
  31:              });
  32:      }, null);
  33:  }

 

This code is easier than it looks. We start off with a HTTPWebRequest for the service (line 6-7) using an HTTP GET (line 9) and a code block to handle the async call (starting on line 11) . This code block works similar to a callback method. Inside the code block we catch the HTTPWebRequest asynchronously and get the results into the implicitly typed local variable var on line 19. After that is just basic LIST stuff, filling the list and adding it as the source of the dataGrid.

image

Pretty easy. Since that was so easy, let’s shake it up a little bit. How about we make the backend database be SQL Azure instead of SQL Server 2008.

Connecting Telerik OpenAccess to SQL Azure

Turns out that using SQL Azure and Telerik OpenAccess is pretty easy. If you have an Azure schema that is the same as your SQL Server 2008 schema, all you have to do it change the connection string in the OpenAccess DAL project’s app.config.  Let’s change our connection string in the DAL project to use SQL Azure like this:

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

 

Line 3 is the server you get from the SQL Azure CTP program and the user name and password is what you set up when you got the CTP. (Don’t have a SQL Azure CTP? Sign up here!)

That is it. When I run it I get the same results, except that the data is coming from SQL Azure and not from SQL Server 2008. I went into my Northwind_Lite database in SQL Azure and edited the first Customer row so I always know the data is coming from SQL Azure:

Update Customers 
Set CompanyName= 'Alfreds Futterkiste SQL Azure'
Where CustomerID='ALFKI'

Now when I run the project, I see the data from SQL Azure:

image

That is all there is too it!

You can get the WCF REST Starter Kit here, the Telerik OpenAccess WCF Wizard here, and the code from this blog post here.

Enjoy!

posted on Tuesday, September 08, 2009 5:09:58 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Sunday, September 06, 2009

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

Telerik OpenAccess WCF Wizard: How-to Video #3- REST Collection from Stephen Forte on Vimeo.

posted on Sunday, September 06, 2009 8:12:34 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Thursday, September 03, 2009

Developers have been using the REST specification for some time. If you are using Microsoft tools, ADO.NET Data Services aka Astoria is a very popular way to work with REST data. What you may not know is that Astoria works on top of WCF and you can write your own REST services outside of the Astoria model using WCF. WCF 3.5 SP1 gives us quite a few hooks to build our own RESTful services, however, it still takes a lot of manual wiring up by the developer. By now you all should know that I hate plumbing code.

Microsoft introduced the WCF REST Starter Kit, a set of WCF extensions and Visual Studio project templates to eliminate the plumbing code when building RESTful service with WCF. The five Visual Studio templates are:

  • REST Singleton Service
  • REST Collection Service
  • ATOM Feed Service
  • ATOMPub Service
  • HTTP Plain XML Service
  •  

    As explained in the developers guide to the WCF REST Starter Kit, the templates do the following:

    REST Singleton Service-Produces a service that defines a sample singleton resource (SampleItem) and the full HTTP interface for interacting with the singleton (GET, POST, PUT, and DELETE) with support for both XML and JSON representations.

    REST Collection Service-Similar to the REST Singleton Service only it also provides support for managing a collection of SampleItem resources.

    Atom Feed Service-Produces a service that exposes a sample Atom feed with dummy data.

    AtomPub Service-Produces a fully functional AtomPub service capable of managing collections of resources as well as media entries.

    HTTP Plain XML Service-Produces a service with simple GET and POST methods that you can build on for plain-old XML (POX) services that don’t fully conform to RESTful design principles, but instead rely only on GET and POST operations.

    While the REST Singleton is interesting, it is only useful if you are exposing one item, so the REST Collection is more suitable for interaction with a database driven dataset. The Atom Feed template is interesting but it is more useful if you are building feeds similar to RSS, so the AtomPub Service is more useful. The POX is a good option if you need to do something custom.

    While the REST WCF Starter Kit also provides some client libraries for easier interaction with your RESTful data, we will focus on the creation of the services.

    You can use Telerik OpenAccess as a data source of your REST Collection service. To do so you have to wire up some code in your svc file. Sound like a lot of work? Enter the OpenAccess WCF Wizard I wrote about before.

     

    If you create a project in Visual Studio to contain your data access layer and another to contain the REST Collection (using the new REST Collection template available from the WCF REST Starter Kit), you can point the Telerik WCF OpenAccess WCF Wizard at the data access layer project and then automatically generate the svc file and the corresponding CS file (shown by the arrow in our Visual Studio solution below.)

    image

    Just for a sanity check, let’s run our service by selecting the svc file and saying “view in browser”. You should see the RESTful XML representation as show below (make sure you turn off feed view in IE):

     image

    Now let’s consume this service from a Silverlight application. The WCF REST Starter Kit provides the developer with two classes, HttpClient and HttpMethodExtensions to help you consume the WCF RESTful service. Unfortunately they are not supported in Silverlight (or at least I can’t figure it out. :) )

    We’ll use plain old HTTPWebRequest instead.  But first I will create a grid in my XAML code like so:

    <data:DataGrid x:Name="dataGridCustomers" AutoGenerateColumns="False" ItemsSource="{Binding}">
        <data:DataGrid.Columns>
            <data:DataGridTextColumn Binding="{Binding Path=CompanyName}" Header="Company Name">
            </data:DataGridTextColumn>
            <data:DataGridTextColumn Binding="{Binding Path=ContactName}" Header="Contact Name">
            </data:DataGridTextColumn>
        </data:DataGrid.Columns>
    </data:DataGrid>

    I will create a LoadData() method to load the data on the page load or a “refresh” button event. Being Silverlight, of course we will use some asynchronous processing.

       1:  private void LoadData()
       2:  {
       3:      //address of your REST Collection service
       4:      string url= "http://localhost:60613/Customers.svc";
       5:      //set up the web resquest
       6:      HttpWebRequest rest = HttpWebRequest.Create(new Uri(url)) as HttpWebRequest;
       7:      //HTTP GET (REST uses the standard HTTP requests)
       8:      rest.Method = "GET";
       9:      //async callback
      10:      rest.BeginGetResponse(new AsyncCallback(ReadAsyncCallBack), rest);
      11:  }

     

    First we have to set a reference to our service in lines 4 & 6. Then we tell the HttpWebRequest to use an HTTP GET (line 8), this is the power of REST, it uses the standard HTTP requests (GET, POST, PUT, DELETE). On line 10 is where we begin our asynchronous call to ReadAsyncCallback() shown here.

       1:  private void ReadAsyncCallBack(IAsyncResult iar)
       2:  {
       3:      
       4:      //catch the HttpWebRequest
       5:      HttpWebRequest rest = (HttpWebRequest)iar.AsyncState;
       6:      HttpWebResponse response = rest.EndGetResponse(iar) as HttpWebResponse;
       7:      
       8:      var result = Customer.GetCustomersFromAtom10Stream(response.GetResponseStream());
       9:      //code block to handle the async call
      10:      this.Dispatcher.BeginInvoke( () =>
      11:          {
      12:              //build a collection (customers)
      13:              var customers = 
      14:                new System.Collections.ObjectModel.ObservableCollection<Customer>();
      15:              foreach (var customer in result)
      16:              {
      17:                  customers.Add(customer);
      18:              }
      19:              //bind to the grid when done
      20:              this.dataGridCustomers.DataContext = customers;
      21:          });
      22:  }

    ReadAsyncCallback() is the handler for the asynchronous call we did in LoadData(). We obtain a reference to the HttpWebRequest (lines 5-6) and then get the results back in line 8. Then we use a code block to build an ObservableCollection of Customers and fill them in a loop of the results (lines 15-18) and bind the data to the grid in line 20. The results are data binded to a grid as shown below.

    image

    Since Silverlight doesn’t support HTTP methods that do an update, we can’t do updates without a wrapper on the server. So we will stop the demo with just the read operation. Remember, if you are using a non-Silverlight client such as ASP.NET you can use the HttpClient and HttpMethodExtensions classes for an easier client coding experience.

    Grab the Telerik OpenAccess WCF Wizard here and the sample code from this blog post here.

    posted on Thursday, September 03, 2009 8:59:03 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
    # Wednesday, September 02, 2009

    I have written a white paper for the Microsoft Oslo team that is available on MSDN here. The paper is titled: “Using Oslo to Speed Up Database Development” and shows how you can use the new M language to model databases, browse that model in Quadrant, and tap into the power of the Oslo Repository.

    The paper shows how the model you make is mapped to TSQL and to SQL Server objects, including Tables and Views. It is pretty cool to see the following M type and its M values and how they will map to a TSQL script to create a People table and INSERT INTO statements for the Steve and Mike rows.

       1:  //Types
       2:  type Person
       3:  {
       4:      Id : Integer32;
       5:      Name : Text#50;
       6:      Age : Integer32;
       7:  }
       8:  //Values
       9:  People:Person*;
      10:  People
      11:  {
      12:      { Id=>1, Name=>"Steve", Age=>36},
      13:      { Id=>2, Name=>"Mike", Age=>29}
      14:  }

     

    The corresponding TSQL will look like this:

       1:  create table [OsloDemo].[People]
       2:  (
       3:    [Age] int not null,
       4:    [Id] int not null,
       5:    [Name] nvarchar(50) not null
       6:  );
       7:  go
       8:   
       9:  insert into [OsloDemo].[People] ([Id], [Name], [Age])
      10:   values (1, N'Steve', 36)
      11:  ;
      12:   
      13:  insert into [OsloDemo].[People] ([Id], [Name], [Age])
      14:   values (2, N'Mike', 29)
      15:  ;
      16:  go

     

    Developers will like to model in M since it will abstract them from the ins and outs of the database.

    In addition the paper shows how to use the repository and how modeled types will benefit from using the repository. In addition I discuss a little abut the DSL capabilities of Oslo using M Languages. What is cool is that I also talk about Telerik’s LINQ to M at the end, and how to use it with the DSL and M languages with Visual Studio and C#.

    You can get the paper here.

    posted on Wednesday, September 02, 2009 9:19:14 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
    # Wednesday, August 26, 2009

    The following video shows how to use the Telerik OpenAccess WCF Wizard with ADO.NET Data Services. The video is done by .NET Ninja in training Peter Bahaa and uses more or less the same code I showed yesterday on my blog. Enjoy!

     

    Telerik OpenAccess WCF Wizard Part II- Astoria from Stephen Forte on Vimeo.

    posted on Wednesday, August 26, 2009 9:20:33 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
    # Tuesday, August 25, 2009

    I have been a big fan of using the RESTful ADO.NET Data Services (aka Astoria). If you want to use Astoria out of the box without any modifications you really have to use the Entity Framework. But as long as you are using a data access library that supports IEnumerable and IQueryable (and IUpdateable to be useful for CRUD) you can use Astoria with just a little bit of extra work. 

    Telerik OpenAccess supports LINQ and IUpdateable and can be used in Astoria as shown here. In a nutshell you have to first create your data access layer, then a web site to host your ADO .NET Data Service and then a client (in our case a Silverlight app.) You would have a solution that will look like this:

    image

    The problem is that if you use anything other than the Entity Framework, you need to do a little extra plumbing. In our case using OpenAccess, you have to create the IQueryable interfaces for all of your entities manually. You would need something like this:

       1:  public IQueryable<Customer> Customers
       2:  {
       3:      get
       4:      {
       5:          return this.scope.Extent<Customer>();
       6:      }
       7:  }

     

    The scope variable you see on line # 5 is an instance of IObjectScope. IObjectScope is how OpenAcces implements the actual data context. According to the OpenAccess team, you have to add a few extra lines of code with these IQueryable interfaces into an “OADataContext” class. To be honest, I don’t want to do that, too much plumbing code.

    Enter the OpenAccess WCF Wizard I wrote about before.

    You can use the Wizard to generate the OADataContext file as well as the Astoria service file. Just point the wizard to the DAL layer file and select Astoria from the menu and generate the files and add them to the project (it is ok to overwrite the original CS file supporting the SVC file, just make sure you have the correct namespaces).

    image

    Now your Astoria service will look like this:

       1:      [System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]
       2:      public class WebDataService : DataService<AstoriaDataContext>
       3:      {
       4:          protected override void HandleException(HandleExceptionArgs args)
       5:          {
       6:              base.HandleException(args);
       7:          }
       8:   
       9:          // This method is called only once to initialize service-wide policies.
      10:          public static void InitializeService(IDataServiceConfiguration config)
      11:          {
      12:              //let all the entities be full access (CRUD)
      13:              config.SetEntitySetAccessRule("*", EntitySetRights.All);
      14:          }
      15:      }
      16:  }

    This is pretty standard Astoria stuff, line #13 does all of the Astoria magic.

    Now let’s look at our Silverlight client.  First let’s create some XAML, I will just show you the DataGrid code here:

       1:  <data:DataGrid Grid.ColumnSpan="2" x:Name="dataGridCustomers" AutoGenerateColumns="False" ItemsSource="{Binding}">
       2:      <data:DataGrid.Columns>
       3:         <data:DataGridTextColumn Binding="{Binding Path=CompanyName}" Header="Company Name"></data:DataGridTextColumn>
       4:         <data:DataGridTextColumn Binding="{Binding Path=ContactName}" Header="Contact Name"></data:DataGridTextColumn>
       5:      </data:DataGrid.Columns>
       6:  </data:DataGrid>

     

    As I wrote the other day, you still have to use a service and call the service asynchronously. In our Silverlight application we will then set a service reference to our Astoria Service, allowing us to write LINQ statements against the RESTful Astoria service.

    image

    Just like before we will have a LoadData() private method that our page load and “refresh” buttons will call. This will use LINQ to talk to the Astoria service and fetch all of the Customers. First we set up a LINQ data context (lines 4-5) and then a LINQ query (lines 8-9). Then we will use a code block (lines 13-14) to catch the async code (instead of a separate event handler) and perform the actual binding to the grid.

       1:  private void LoadData()
       2:  {
       3:      //this uses the LINQ to REST proxy (WebDataService)
       4:      AstoriaDataContext dat = new AstoriaDataContext(
       5:          new Uri("WebDataService.svc", UriKind.Relative));
       6:      
       7:      //link statement to get the data, can use WHERE, Orderby, etc
       8:      var customers = 
       9:          (from c in dat.Customers select c) as DataServiceQuery<WebDataService.Customer>;
      10:   
      11:      //use code block to perform the binding at the end of the async call
      12:      //casting the Customers to a LIST
      13:      customers.BeginExecute(
      14:          (ar) => dataGridCustomers.DataContext = customers.EndExecute(ar).ToList(), null);
      15:  }

    When we run our code, we will get data right away:

    image

    We can also perform an update. We have a global collection called editedCustomers and we trap the BeginEdit method of the Silverlight grid and put an instance of each row (a Customer) that was edited into this collection. Then we provide an update button that will call UpdateData() shown below. UpdateData() will loop through each dirty customer in the editedCustomers collection (lines 8-11) and update them using the Astoria LINQ services (lines 10-11). Inside of our loop we are doing another code block (lines 12-25) to catch the async update. We use a counter to figure out when we are done (lines 16-22), since in an async model, your 3rd update out of 5 can be the last one to finish!

     

       1:  private void UpdateData()
       2:  {
       3:      //this uses the LINQ to REST proxy (WebDataService)
       4:      AstoriaDataContext dat = new AstoriaDataContext(
       5:          new Uri("WebDataService.svc", UriKind.Relative));
       6:   
       7:      //editedCustomers is a local collection containing only the dirty records
       8:      foreach (WebDataService.Customer customer in editedCustomers)
       9:      {
      10:          dat.AttachTo("Customers", customer);
      11:          dat.UpdateObject(customer);
      12:          //code block to handle the async call to updates
      13:          dat.BeginSaveChanges(
      14:              (ar) =>
      15:              {
      16:                  updatedCounter++;
      17:                  //once we are finished with all items in the collection, we are done
      18:                  if (updatedCounter == this.editedCustomers.Count)
      19:                  {
      20:                      MessageBox.Show("Customers have been changed successfull!", "Saving Changes", MessageBoxButton.OK);
      21:                      this.editedCustomers.Clear();
      22:                  }
      23:   
      24:                  dat.EndSaveChanges(ar);
      25:              }
      26:              , null);
      27:      }
      28:  }

     

    That is it to build an Astoria based Silverlight application using OpenAccess. The OpenAccess WCF Wizard takes care of building the OpenAccess specific plumbing DataContext class for you as well as the Astoria service. Soon I will post another video by .NET Ninja in training Peter Bahaa on this demo as well as some more code examples using the WCF REST Toolkit and the OpenAccess WCF Wizard.

    The code is available here. Enjoy!

    posted on Tuesday, August 25, 2009 11:31:37 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
    # Sunday, August 23, 2009

    Last week I showed how to use the Telerik OpenAccess WCF Wizard on this blog. The wizard creates some of the boring WCF code for you automatically. You can create endpoints for WCF, Astoria, REST collection and ATOM Pub services. Our first demo used WCF, later we will show you the other services. This is what we did:

    • Created a data access layer automatically using OpenAccess
    • Created a WCF Service automatically using the wizard
    • Created a Silverlight 3.0 application that used WCF to databind the Customers table to a datagrid, enabling editing automatically

    Here is a video by Peter Bahaa (aka Pedro), .NET ninja in training, using the wizard with the above scenario. You can get the code here. Enjoy!

    Telerik OpenAccess WCF Wizard Part I from Stephen Forte on Vimeo.

    posted on Sunday, August 23, 2009 7:34:48 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
    # Wednesday, August 19, 2009

    Microsoft’s Silverlight 3.0 is a great new platform for building line of business applications. With every new technology advancement, we always seem to lose something. With Silverlight we lose the dirt simple data access since Silverlight does not support System.Data.SQLClient and talking to a database directly. This forces us into a service oriented architecture and an asynchronous model. While this is definitely a best practice, it sometimes takes a little getting used to.

    With Silverlight we have to wrap up our data access layer into WCF services. (Or Astoria, RIA Services, or something similar.) It is also pretty standard to use some kind of ORM like the Entity Framework or Telerik OpenAccess to map to your database tables and then expose those entities as part of your WCF service. Mapping tables to entities may save you time, however, the part that bothers me is that there is a lot of generic “plumbing” code that has to get written for the WCF service to function.

    That is why Telerik created the OpenAccess WCF Wizard. The Telerik OpenAccess WCF Wizard is a tool that will automatically create the C# “plumbing” code and necessary project files for using OpenAccess entities with the following services:

    • Astoria (ADO .NET Data Services)
    • WCF
    • REST Collection Services (WCF REST Starter Kit)
    • ATOM Publishing Services (WCF REST Starter Kit)

    Using the wizard is pretty easy. If you already have a project with OpenAccess mapped entities in it, all you have to do is point the wizard to that location and have it generate the scv and .cs files of the WCF service (or Astoria, REST Collection or ATOM Pub service) as shown below. This will eliminate the need for you to write all of the WCF plumbing code.

    image

     

    We’ll map the Northwind tables and run the wizard and then create a WCF service project. Once you create the service, replace the .cs file with the one generated by the wizard and then create a new Silverlight project (or any project that wants to communicate with your OpenAccess enabled WCF service.) Then set a Service Reference to the WCF service and you can start to consume the it. Your projects in the solution will look like this:

    image

    Where:

    • OA.WCFWizard.Demo.DAL is the project containing your OpenAccess entities (mapped to Northwind tables).
    • OA.WCFWizard.Demo.SL is the project containing your Silverlight project, including the service reference to your WCF service. (First arrow.)
    • OA.WCFWizard.Demo.WCFService is the project containing the WCF service created by the WCF wizard (second arrow.)
    • OA.WCFWizard.Demo.Web is the asp.net site hosting your Silverlight application

    Writing some Silverlight code to consume the WCF service

    Consuming the service is pretty easy once you have the service reference set up. We’ll start with some basic XAML, but I will spare you the major XAML details since I am not a XAML expert. Here is my datagrid in XAML, notice that I am using data binding and predefined columns to make life a little easier:

    <data:DataGrid x:Name="dataGridCustomers" Grid.ColumnSpan="2" AutoGenerateColumns="False" ItemsSource="{Binding}">
         <data:DataGrid.Columns>
             <data:DataGridTextColumn Binding="{Binding Path=CompanyName}" Header="Company Name"></data:DataGridTextColumn>
             <data:DataGridTextColumn Binding="{Binding Path=ContactName}" Header="Contact Name"></data:DataGridTextColumn>
         </data:DataGrid.Columns>
    </data:DataGrid>

    When filled, it looks like this:

    image

    Pretty basic stuff, if you want more advanced looking grids and controls, talk to a designer. :)

    Ok, so how can we easily consume this service and bring this data from Northwind via OpenAccess and WCF to the Silverlight grid? Once you have a service reference set up (NorthwindWCFService) in your Silverlight project, you have to do a few things to call it. I created a LoadData() method to contain the code to fill the grid. We can call this on the page load event as well as on the UI with a “refresh” button, or after any “save” method.

    Inside of the LoadData() method, first you have to create an instance of the proxy or the “client” as shown in line 4 of the first code block below. Once you have this set up, you then have to register an event for the method you are going to call, as shown on line 6 below. This means that when you call your ReadCustomers method asynchronously the client_ReadCustomersCompleted event handler will fire when the ReadCustomers method is done. This is where you put your binding code (more on that in a second.)  Lastly we have to call our ReadCustomers method, we can only call the asynchronous version of this method as shown in line 9.

       1:  private void LoadData()
       2:  {
       3:      //ref to our service proxy
       4:      NorthwindWCFService.SampleWCFServiceClient wcf = new NorthwindWCFService.SampleWCFServiceClient();
       5:      //register the event handler-can move this up if you want
       6:      wcf.ReadCustomersCompleted += new EventHandler<NorthwindWCFService.ReadCustomersCompletedEventArgs>(client_ReadCustomersCompleted);
       7:      //make an async call to ReadCustomer method of our WCF serice
       8:      //get only the first 100 records (default)
       9:      wcf.ReadCustomersAsync(0, 100);
      10:  }

     

    The code for the event handler is pretty straightforward, we just set the datagrid’s DataContext to the e.Result of the event handler. This will contain an ObservableCollection<Customers> that was defined automatically for you via the proxy when you created your service reference.

       1:  void client_ReadCustomersCompleted(object sender, OA.WCFWizard.Demo.SL.NorthwindWCFService.ReadCustomersCompletedEventArgs e)
       2:  {
       3:      dataGridCustomers.DataContext = e.Result; 
       4:  }

     

    That is it! I will soon post a video here showing how to do this in more detail as well as an update method since our grid is editable (it is super easy.) Next week I will show some examples using ADO .NET Data Services (Astoria) where the wizard will also automatically create the IObjectScope OpenAccess and Astoria plumbing code for you.

    posted on Wednesday, August 19, 2009 6:04:20 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
    # Friday, July 31, 2009

    If case you did not know, Telerik released LINQ to M a few weeks ago, enabling you to use a LINQ style interface with M values of data. Mehfuz and I have written blog posts where you can see how to use the basics. 

    There have been tremendous amounts of downloads and we have gotten tons of feedback. (Thanks, keep it coming!) One thing that stood out is that when you are building M values a lot of time you will have a named instance of your M code like this:

       1:  //People is the named "M" instance
       2:  People{
       3:                  {Id=1,Name="Stephen Forte",Age=37},
       4:                  {Id=2,Name="Mehfuz Hossain",Age=29},
       5:                  {Id=3,Name="Vassil Terziev",Age=31},
       6:                  {Id=4,Name="Nadia Terziev",Age=27},
       7:                  {Id=5,Name="Chris Sells",Age=37},
       8:                  {Id=6,Name="Todd Anglin",Age=27},
       9:                  {Id=7,Name="Joel Semeniuk",Age=37},
      10:                  {Id=8,Name="Richard Campbell",Age=42},
      11:                  {Id=9,Name="Kathleen Gurbisz",Age=31}
      12:   }";    

     

    In the first version of LINQ to M, you get a runtime error saying that LINQ to M cannot parse “People”. The most current refresh of LINQ to M fixes this problem and you can run your LINQ queries against M values that have a named instance. You can get the refresh here. Enjoy!

    posted on Friday, July 31, 2009 12:25:00 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
    # Wednesday, July 08, 2009

    I have been using Microsoft “Oslo” for some time and have been pretty excited about the ability to model an application and store it in the repository. Other developers have also gotten very excited about the ability to create domain specific languages (DSLs). DSLs are cool, because if you build a DSL on top of your application, you can abstract away some of the hard to understand stuff. You can also put in a layer on top of your standard communication (DALs, web services, etc.) For example, let’s say you work at Expedia and you want to give your providers (the airlines) a way to enter flight data to your site. You will most likely have a data entry screen with lots of boxes and drop downs. An alternative of course is a Web Service as well as a CSV text import. But another alternative is to provide a DSL, so if someone wants to go in and make a quick change, they can type:

    Delta flight 280 on Friday’s new price is $780.

    Then using Oslo, you can transform this to an M Value format:

    Flights
    
    {
    
    {Carrier=”Delta”, Flight=280, DepartDate=”July 10, 2009”, Price=780}
    
    }

    This is one area where you can use Oslo with .NET today-you can call the M DSL DLLs from .NET and perform the transformation in C# or VB. The problem is that the M Value format is difficult to work with in .NET; parsing the M values can be a challenge.

    Mehfuz Hossain over at Telerik built a LINQ Extender available on codeplex. Building on top that, Telerik has released a LINQ to M implementation. It is pretty easy to use. After you download it and set a reference to it in your application, you then use standard LINQ statements against M Values.

    For example, let’s say that your application has some M values that looks like this:

       1:   {                
       2:           {Id=1,Name=""Stephen Forte"",Age=37},
       3:           {Id=2,Name=""Mehfuz Hossain"",Age=29},
       4:           {Id=3,Name=""Vassil Terziev"",Age=31},
       5:           {Id=4,Name=""Nadia Terziev"",Age=27},
       6:           {Id=5,Name=""Chris Sells"",Age=37},
       7:           {Id=6,Name=""Todd Anglin"",Age=27},
       8:           {Id=7,Name=""Joel Semeniuk"",Age=37},
       9:           {Id=8,Name=""Richard Campbell"",Age=42},
      10:           {Id=9,Name=""Kathleen Gurbisz"",Age=31}
      11:   }

     

    You could have gotten this M code from the results of a DSL or some other process. For our purpose, we will just put it into a constant and query against it:

     

    const string MGraphCode = @"

                {

                   

                    {Id=1,Name=""Stephen Forte"",Age=37},

                    {Id=2,Name=""Mehfuz Hossain"",Age=29},

                    {Id=3,Name=""Vassil Terziev"",Age=31},

                    {Id=4,Name=""Nadia Terziev"",Age=27},

                    {Id=5,Name=""Chris Sells"",Age=37},

                    {Id=6,Name=""Todd Anglin"",Age=27},

                    {Id=7,Name=""Joel Semeniuk"",Age=37},

                    {Id=8,Name=""Richard Campbell"",Age=42},

                    {Id=9,Name=""Kathleen Gurbisz"",Age=31}

                }";

    Now you need to load the M code into a QueryContext object so you can work with it in LINQ:

       1:  var personM = QueryContext.Instance.Load(MGraphCode);

    There is not a ton you can do with it just yet, but you can bind it to an ASP.NET data grid:

       1:  GridView1.DataSource = personM;
       2:  GridView1.DataBind();

    This alone will save you some time, but if you want to do typed queries and have the cool IntelliSense experience, you have to strongly type your LINQ statement. To do this, create a class that has the same shape as your M data, so we will create a Person class:

       1:  public class Person
       2:  {
       3:  public int Id { get; set; }
       4:  public string Name { get; set; }
       5:  public int Age { get; set; }
       6:  }

     

    Now it gets fun. Let’s create a simple LINQ statement that will query just the 37 year old people not named Joel Semeniuk:

       1:  var persons = QueryContext.Instance.Load<Person>(MGraphCode);
       2:   
       3:  var result = from person in persons
       4:                where person.Age == 37 && person.Name != "Joel Semeniuk"
       5:                orderby person.Name ascending
       6:                select person;

    This will return just Chris and Stephen. You can see that we are using the standard LINQ statements FROM, WHERE, ORDERBY, and SELECT. (Hey wait a minute, aren’t those SQL operators, but I digress…. )

    Let’s do some aggregation, this query will aggregate a list all of the ages and count how many people are that age, but we will exclude from our query any age that only has one person:

       1:  //Using a Group By and SUM
       2:   var result1 = from person in persons
       3:                 group person by person.Age into g                         
       4:                 where g.Count() > 1
       5:                 orderby g.Count() descending
       6:                 select new { Age = g.Key, Count = g.Count() };

    Your results will look like this:

     

    Age

    Count

    37

    3

    31

    2

    27

    2

    Lastly, just for the true geeks, here is how to use a LAMBDA expression:

       1:  GridView3.DataSource = QueryContext.Instance.Load<Person>(MGraphCode)
       2:                         .Where(p => p.Name == "Mehfuz Hossain");
       3:  GridView3.DataBind();

     

    Mehfuz and I are pretty excited about this. There are some limitations; the M Values that you pass in has to be shaped without a name as you can see above. (Don’t worry we will change that later on.) But what you can do so far is pretty darn cool. Enjoy and drop a comment to me or Mehfuz about what you want to see in the next release.

    Download it here.

    posted on Wednesday, July 08, 2009 11:31:05 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
    # Monday, January 26, 2009

    Due to my comment spam problem, the link to the ORM white paper I wrote got deleted. A month or so ago, I wrote a white paper for Telerik on ORMs in general and their ORM in particular. This white paper is mostly an intro to data access layers, what an ORM will give you and how they work. Here is the link.

    posted on Monday, January 26, 2009 10:54:18 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
    # Tuesday, May 06, 2008

    We're looking to hire a few good .NET developers. Instead of the traditional way of sending in CVs (resumes), I figured we can do this Web 2.5 style. Resumes are so 20th century and Web 1.0. What can we learn about you with just a resume?

    Below are 10 things I want you to send me: some easy, some hard, some fun, some coding challenges. There are no right or wrong answers this is just a way for us to get to know you. Some questions will take you 5 seconds, some may take you 5 minutes, and at least one will take you an hour (#7, but it is fun). I am looking for what drives you, where you want to go, and of course your approach to problems and how you craft a solution. For the coding questions, good coders are easy to find, I am looking for a coder who in creative (one guy once solved a TSQL problem better than the actual official solution and now I use his answer as the new solution) but also through. (Hint: check your own work a gizillion different ways, I have gotten compile errors back in the past!) I am also looking for some who takes pride in their work and goes the extra mile (or kilometer). (Hint: things like good Unit tests also give you bonus points.) After we get to know each other via this process, then I will look at your CV and we can do the traditional interview.

    Good luck and HAVE FUN!

    1. Send me a link to you online. Your web page, blog, MySpace profile, user group you are a member of, or a site that you worked on. Anything to get me acquainted with you. If you are reading this blog you already know me, so it is only fair. :)

    2. List your top 5 values. (Why do you get out of bed in the morning? What makes you tick?)

    3. List the top 3 blogs that you read and tell me why.

    4. Tell me what programming language you want to learn next and why.

    5. List the top 3 new features you want to see in the next version of the .NET framework (4.0) that has not been announced and tell me why you want to see them.

    6. Write a short essay on the greatest failure (canceled or late project, bad code breaking the build the night before a major demo, etc) in your professional career.

    7. Listen to this podcast. Reflect on it and give me your reaction to it.

    8. Send me an ASP.NET project from Northwind that uses the Model View Controller design pattern. (Not the ASP .NET MVC framework.) Use the categories, products, and sales. Be creative. Bonus points if it is real easy to install.

    9. A TSQL Challenge. Give me a script to solve the following problem. (Run this setup here.) There are no real wrong answers, but the more efficient and bulletproof the query is the better. No cheating and no cursors! Don't Google the answers (we'll know.) Assign rooms to classes based on capacity using the Classes and Rooms tables. Rules: each class should have a room (and NULL if a room is not available). No class can be in a room where there are more students than capacity. No room can be used twice.

    The results of your SQL statement should be something like this:

    image

    10. Create a data driven ASP.NET page using the Telerik controls. Tell me something that sucks about the control you used. (I already know what is great about them.) Bonus if you find a bug. (We'll send you a .NET Ninja tee shirt if you do.)

    posted on Tuesday, May 06, 2008 9:41:07 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [1] Trackback
    # Thursday, May 01, 2008

    Red Herring magazine, an influential .com survivor, compiles a list of the most important firms in the technology and bio-tech space. The companies that innovate and set trends and influence the market. This is like the Fortune 500 list but for tech. This is an important list, in the past Google and Amazon were at the top.

    The List of the Top 100 European Companies is now out and Telerik is on that list. This great for Telerik of course but even better for the .NET community. First it shows that .NET is gaining more and more momentum when Red Herring awards a .NET component vendor as innovative, influential, and trend-setting. (They usually reserve those terms for open source.)

    Second it show just how global our community is, Telerik is an Eastern European company with headquarters in Sofia, Bulgaria, and one of only three companies on the Red Herring 100 from the former Eastern Block. That a company's founders grew up under communism and then can be labeled by Red Herring as innovative and influential in our market is totally awesome. Shows you how technology (and .NET!) can change the world.

    Congratulations to the .NET community and to Telerik.

    posted on Thursday, May 01, 2008 11:40:50 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback