v3 tech on a v1 body

imageNew Database, relay boards, Linq To Sql backend now work with the old user interface.  Right now there are 2 things not hooked up, the images as you can see and the progress bars for pouring.  With Expression Blend 3’s support for Illustrator, I realized I could port the PSD’s which are vector based into Illustrator.  The gradients won’t port 100% nicely but I can redo those in Illustrator.  The glasses also were made by Ian Hall if I haven’t mentioned that before.

I did a decent chunk of axe sharpening building this new version.  It has some pretty nice admin tools now which are done in Win32 currently as I’m not 100% comfortable with WPF yet.  Doing the last bits of logic today, I know there are still chances are some bugs as when I was writing the code, I didn’t expect LINQ to act in certain ways.

var listOfDrinks = from d in GetPossibleDrinkListByPartialName("")
					   select d.DrinkId;

var returnVal = (from uh in user.UserHistories
				 where listOfDrinks.Contains(uh.DrinkId)
				 orderby uh.UserHistoryId descending
				 select uh).Take(1);

return (returnVal == null) ? null : returnVal.SingleOrDefault().Drink;

Now if I didn’t have the Take(1) and just used SingleOrDefault(), LINQ would throw an exception if more than one object was returned.  I would have thought it would have just returned the top result.  Another thing that acted weird in my opinion is when I would use just Single().  If it didn’t have an object to return, I would expect a null returned.  Not the case.  It returned a nice exception instead.  I’m not sure yet about the SingleOrDefault() return as well.  I think my object IDs will have an ID of 0.  If this is the case, it is very easy to tell.

Now to make this application actually be WPF instead of just looking like it is WPF.  I have to get with the times and figure out how to do a proper Model-View-ViewModel application first.  I did find a sweet WPF library by Kevin Moore (http://j832.com/bagotricks/) called The WPF Bag-O-Tricks.  I’m thinking I’m going to use his Grid since the animation style I want is already built into his.

Also a nice gentleman from across the pond, Ross Dargan (http://blog.the-dargans.co.uk) came up with a different way of doing the SQL call to return all items the system can currently make.  I did learn a few things about SQL which could make my query a bit cleaner but I think the two queries are about the same.

Jérémie Apr 23, 2009 @ 10:23 AM

# re: v3 tech on a v1 body
You can use FirstOrDefault(),
it returns null if your enumerable is empty, and the first item if it contains one or more.. I think its what you was looking for.

Post a Comment

Please add 4 and 1 and type the answer here: