mha.dk

Random thoughts of wisdom - the personal blog of Michael Holm Andersen

LINQtoSQL – Grouping and selecting

I have a Order->OrderLine table setup where I need to check if any “duplicate” orders exists. In order to check this I need to be able to select select various columns *not* contained in the group (key) – playing around in LinqPad I quickly came up with this query:

from line in AxSaleLines
where line.QuantityRemaining > 0
group line by new {line.AxSale.AccountNumber, line.ItemNumber, 
ProdName = line.Product.Name, ProdFormat = line.Product.ProductFormat.Name}
into myGroup
where myGroup.Count() > 1
from s in AxSaleLines
where s.ItemNumber == myGroup.Key.ItemNumber && 
      s.AxSale.AccountNumber == myGroup.Key.AccountNumber
select new { s.AxSale.SalesId, s.AxSale.AccountNumber, 
             CustomerName = s.AxSale.Customer.Name, s.ItemNumber, 
             ProductName = s.Product.Name, s.Product.ProductFormatName, 
             s.Quantity, s.AxSale.SalesOrigin}
 


When bound to a grid, I can then show this to the user:

groupedgrid

Register Custom Controls In Web.config

If you’re using a lot of UserControls or a control package, you’re probably finding yourself adding tons of <%@ Register… %> tags to your .aspx pages.

Phil Haack has an excellent post about how to avoid all this mess and put your assembly references into the Web.Config file. Go check it out!

Slide Screen for Android

slidescreenui If you’re an Android fan (as I am) and thinks the stock homescreen is really not that great/usable, you should take a look at SlideScreen

SlideScreen is a homescreen replacement, which totally changes how you use your phone.

The cool thing about SlideScreen is that it integrates information from various sources—Google Reader, Twitter, Facebook, email, text messages, calendar appointments and stocks—right onto the homescreen

If you’re a proud Android user, be sure to check it out!