Jim Jackson

Character Counts.
Do the right thing.

Sponsors

August 2009 - Posts

RIA Services - Iterate Items in EntityQuery Object

I’m trying to get EF working with SL3, SSL, RIA Services et al. It’s a long road and I know there are issues with any route you decide to take when building a business app in Silverlight 3. In building previous iterations of my little program I used straight WCF services and had issues with host headers when using SSL and the cross domain access file.

RIA Services is definitely easier to work with in terms of the plumbing. It sets up a new handler in the web.config and if you work out your EF model properly, the data access and communications portions go relatively quickly.

The issue I was working through this evening was that I am using the ESRI mapping control and I could not get it to databind the graphics layer to a collection of graphics objects bound to a data context query. The backup plan is to iterate items in the data context query results. Good luck finding a helper post anywhere to write that Linq query! So here is one I finally found in a forum post on the RIA Services list. I lost the URL but here is the relavent code:

// Instance the list of objects we’ll use to
// build the map graphics.
List<MyMapPoint> lst = new List<MyMapPoint>();
// Query that gets the list of points from
// the database.
var queryhist = _MyContext.GetPointsQuery();
// Execute the query.
var qOp = _MyContext.Load(qhist, (pts) =>
{
    foreach (var pt in pts.Entities)
    {
        lst.Add(
                new MyMapPoint(
                pt.PointID,
                pt.PointName, 
                pt.Latitude,
                pt.Longitude
                );
    }
}, null);

I know I could probably serialize my query results directly into my list but I’m just not there yet (read: I don’t know how to do that!).

The points of interest viewer/editor should be up fairly soon at www.muddygps.com. Some time thereafter, the GPS trail routing will also get rolling and then I can start fooling with the race interface. That will be the fun part! Incidentally, the app as it exists right now on the internet is being completely rewritten (again) so it should get a lot faster soon.

Another item up for bids is going to be trying to work out why the cross domain access policy isn’t working right. If I make the entire SilverLight 3 portion of the site SSL it works but as soon as I make it SSL only for the RIA Services data calls, it makes squishing noises. Not going to worry about that one for now because the data access seems to be going relatively quickly for the size of data I’m throwing around.

I’m also building on some of Brad Abrams tutorials for SEO and deep linking. Hopefully that will get my site some traffic. Of course I can’t expect much at the moment since I’ve got a face but no content online.

More Posts