Using the Entity Framework in a Layered Architecture
Thursday, July 03 2008 - entity-framework, data-points, wcf, mvp, msdn-magazine - 1 comments
My July 2008 Data Points column was just released on the MSDN Magazine web site. This month I demonstrate how to use the Entity Framework in a multi-tiered architecture passing entities through the layers via WCF. The code sample is available from their web site too.
The Entity Framework has been a much discussed topic of late. Many articles discuss and show how to build different types of models and facets of the Entity Framework. This article shows one way to integrate the Entity Framework’s models into an application that uses layers and a form of the MVP pattern.
Silverlight Presentations On the Horizon
Thursday, June 19 2008 - silverlight, wcf, camtasia, video - 2 comments
I am sitting down writing about WCF interaction with Silverlight, cross domain issues, and other fun communication stuff. As I am drumming through these examples for the book and for some articles and presentations (phew) I am running into minor issues that really cause me to think differently about how to tackle them. For example, I wanted to produce a model popup window in Silverlight. Sure, no problem, I’ll just use the … wait … there is no modal popup control. There is a popup control, but its not modal. And it lacks a bit of refinement. I see from my friend Mr Google that others have tackled this issue in various ways … such as …
- Creating an abstract class that derives from the ContentControl and implementing methods that render the popup
- Creating a popup control inline in code, and restricting keyboard and mouse movement beyond the popup control
For now, since I could not find an elegant solution that I could fall in love with, I decided to create a popup control in a user control and expose custom properties on the user control so I could tweak the popup control and simulate modality. The user control has a canvas that stretches out over the base Silverlight control with a 50% opacity. This simulates a graying out of the background when the popup control appears and prevents mouse interaction. It does not prevent tabbing back into the originating Silverlight application, but that;s next on my list. It ain’t perfect, but it works good enough for now. I have to think that there will be an easier way to simulate modality in the future, at least by RTM.
Anyway … this and other issues like it got me to thinking that it might be a good thing to present some of these issues I am running into on my blog in narrative form like this post, in code samples, and in camtasia vdeos. I’ve got plenty to share … the only catch is finding the time between my main job, my speaking schedule, and my writing schedule and leave time for the family. The same ol’ battle :) But I think I will have some time to do some quick videos and postings on these topics so here’s my vow to share some of my Silverlight adventures, both successful and unsuccessful, in the coming weeks and months. The first will likely be on the modal popup that I described in this post. My hopes are that this sharing process will help refine some of these bumps in the road for Silverlight junkies like me.
Silverlight Consuming REST Services
Friday, May 16 2008 - silverlight, rest, linq, xml, wcf, book - 3 comments
I just finished writing the first draft of a sample I am including in my upcoming book tentatively titled Data Access with Silverlight 2 by O'Reilly. Without giving too much away yet since the final details of the contract are not set in stone, the application example consumes a REST service, manipulates it through LINQ to XML, and binds it to various controls and some composite controls. The interaction with the REST (REpresentational State Transfer) services is pretty slick and quite easy when using Silverlight and LINQ to XML. Of course there are always issues to deal with, but overall it works very nicely.
Why use REST? Well, REST services are becoming more abundant on the web. They do not expose a contract like WCF so when you deal with this type of data you can parse the XML using LINQ to XML or some other XML tools (though LINQ TO XML is so smooth why bother with anything else in this case). So this raw XML comes barreling into your Silverlight application asynchronously, LINQ to XML makes it fall in line, and its bound to where it needs to go via XAML.
Sending data back via REST is also very cool. I've got that working now too. I have to be careful not to go overboard fine tuning the examples though or the book will never get written :) Interacting with REST from Silverlight applications is just one piece of the data access puzzle, but its pretty cool.

Silverlight, WCF and LINQ to SQL
Wednesday, May 07 2008 - silverlight, entity-framework, linq, sql, wcf - 1 comments
I've had some requests lately to write some articles that work with LINQ to SQL. I've ben focusing on the Entity Framework a lot due to its vast nature and that fact that its still relatively unknown to many people. So I am going to work on a LINQ to SQL project that ties into a multi tier model. I am also going to show how this can be hooked into a Silverlight 2 UI that connects through WCF to the lower layers.
I'll probably be demonstrating these first at an event I am trying to set up with Joe Healy of Microsoft in Tampa this coming August. The demos will be ready way before then, but I wanted to have some cool materials for this event. There is no title nor date yet, but once the event is set I will be sure to let blog about it. It should be a great day overall.
I also plan on giving some love to the Entity Framework, regular persistence/mapper models, MVP patterns and more. I just have to find a way to work it all in and still give enough to each topic. Of course, this means all demos are subject to change, but the content will be fresh and cool for certain.
Here is a very poorly and quickly thrown together diagram of one of the demos I am tweaking.
Good Series of WCF 101 Posts
Monday, April 28 2008 - wcf - 0 comments
Ironically, I had a problem with WCF configuration last night and found myself googling for answers. It turns out my problem was quite simply resolved once I realized I forgot to put my app.config in the bin folder of my multi layered application, but in the process I ran across some good posts by Sahil.
My friend Sahil Malik has been posting a series of posts on WCF recently. Here is a nice hello world post that demonstrates how to create a simple WCF application and run it using VS.NET to self host the services and test it. Its a nice post because it cuts out all of the garbage that often accompanies any discussion on WCF.
Sahil also addresses the basics of WCF in this post. its a good read for those diving in. He also has a post that discusses how to create a WCF client and another post that demonstrates how to host WCF services in IIS.
Why do I like these posts? Because Sahil, as usual, takes what can be a complicated topic and breaks it down into some basic areas to focus on.
WCF Configuration - Simple Oversight
Monday, April 28 2008 - wcf, mvp, wpf - 1 comments
Last night I had a problem with getting WCF to work with my application. I had a very simple scenario intermixed in a multi-layered application. The error I kept getting was
Could not find default endpoint element that references contract MyServiceHost.IMyService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
I kept looking at the config files using the SvcConfigEditor.exe utility and made sure the client and the server configurations were set up properly and matched each other. I was convinced I had done it right, so I started googling for answers. I was sure it was something simple. Well, it turns out that it was a simple mistake I made. I did not find anything by googling, so I figured I would post this in hopes of helping others and myself in case I do this again someday :)
My application has a UI layer for the views (using WinForms, WPF, etc) and a second project layer for presenters (using the MVP passive view pattern). The presenter project is what communicates with the WCF Service via its host but the app runs from the UI layer. This means that the client config must be accessible from the UI's exe. I had placed the config file in the presenter project because this is where I had set up the service reference to the WCF services. Once I realized that I forgot to copy the config file to the UI project I had a "doh!" moment.
So in short, the problem It turns out my problem was quite simply resolved once I realized I forgot to put my app.config file in the bin folder of my multi layered application's startup project.


Email

