LINQ

My LINQ Articles

I have been doing some LINQ/DLINQ articles over at codeproject.

Codeproject article link :LINQ Introduction 1 of 3

Heres a small taster of some of the LINQ standard query operators I discuss
in the article (the acticle does them all)

Where

var iSmall = 
    from it in _itemList 
    where it.UnitPrice < 50.00M 
    select it;

Select

 var namesAndPrices = 
     _itemList.Where(i => i.UnitPrice >= 10). 
Select(i => new { i.ItemName,i.UnitPrice }).ToList();

Take

var MostExpensive2 = _itemList. 
OrderByDescending(i => i.UnitPrice).Take(2);

Join

var itemOrders =    from i in _itemList 
join o in _orderList on i.ItemID equals o.OrderID 
select new { i.ItemName, o.OrderName };

GroupBy

var itemNamesByCategory =    from i in _itemList 
group i by i.Category into g 
select new { Category = g.Key, Items = g };

Intersect

var inter = (from i in _itemList select i.ItemID).Distinct() 
.Intersect((from o in _orderList select o.OrderID).Distinct());

ToArray

var query = _itemList.ToArray(). 
Where(i => i.Category.Equals"Food"));

Count

var foodCat = (from i in _itemList 
where i.Category.Equals("Food")  

select i).Count();

Sum

var totals = (from i in _itemList select i.UnitPrice).Sum();

Thats really only a few of the LINQ standard query operator, there are many many more
mentioned at the article link at the top of this section.

Ive also be doign some DLINQ stuff, and done an article about that as well.

Codeproject article link :DLINQ Introduction 2 of 3

This article discusses the use of the DLINQ designer, the enitity code file generation using the SQLMetal.exe tool,
and also shows some standard DLINQ queries and updates in action

I’ve even attracted the attention of a Mr Joe Rattz, who is just about to publish a LINQ book his blog is here LINQDev.com he liked my articles, as did the totally awesome Marc Clifton. So I must be something right. You decide.

Hope you like them

Advertisements
Current Work

Visual Studio Templates “Out Of Date”

Today I started up my beloved Visual Studio 2005, and it said “No Visual Studio template information found”. Mmm. Bad news. Accepting this message, all my normal project types (templates) were not present. It turns out this is easiliy fixed with the following command line

C:Program FilesMicrosoft Visual Studio 8VC>devenv /installvstemplates

So if you get this message, simplu use that command line, and bingo your good to go again

Current Work, Significant Projects (Shareable)

NetPics : My MSc Project

NetPics Web Site : NetPics

I am currently doing my Msc at Sussex University, and as for my degree we have to do a final project. So I chose to do something like Flickr, where people could share media with friends. At the moment I only allow images to be shared, but this could be any media, such as video, music, documents etc etc.

The idea is that a web user may share with their friends, and the freind can log into the same portal and view the shared content. But I also wanted to write an app, that would allow the user to upload very quickly using standard desktop techniques such as drag and drop. In fact they should not even be aware that they actually creating web content. To this end the project will use a dektop application, and an ASP .NET web app, and the desktop app will upload content using a web service. Thats the basic idea anyway.

Although I am still doing my MSc, and this project is still under development. A few screen shots cant hurt now can it.

The Web Site

This uses ASP .NET, and will use custom ASP .NET controls, and Ajax to allow the user to drag around pictures to form new albums etc etc

np1.png

np2.png

np3.png

np4.png

The Desktop App

The desktop app is .NET 2.0 stuff all the way. C# of course. The user of the desktop app will be able to create albums, edit images, view a slide show of image etc

np5.png

np6.png

np7.png

The image editing is done, thanks to the use of the IPLab image processing library, by Andrew Kirillov. The IPLab is available here

I am hoping this will do even better than my BSc project. Ill let you know when ive done it, and its marked.

Employment

Some Other Areas That Ive Also Worked In

Obviously when one is employed (as I have been since I was about 18 or so, even during my degree) one has to be mindful of keeping customer sensitive information, private. As such I have worked on many many interesting projects that you would all love, but alas I can not share code for, as it is private customer data.

I can however state the application of some of the more exotic systems that I have worked on :

  • Colourant plant automation and recipe management system, for Clairol hair dye (yes them on TV)
  • Serial comms protocol definitions for some very wacky serial comms stuff, talking to C# code. My boss at the time did the code.
  • Assisted in the development of our own automation layer written entirely in C#, with support for OPC
  • Support for numerous blue chip UK based companies
  • Integration of Management Excecution Systems world wide for Procter & Gamble
Significant Projects (Shareable)

ReMp3 : My BSc Project

ReMp3 Web Site : ReMp3 | Sussex University : Prizewinning projects

For my final year degree project at Sussex University (2006), I decided to write an application that would allow the following features:

  • Allow a user to construct a local playlist of music
  • Allow a user to RIP a CD to MP3 / WAV
  • Allow a user to create a media catalogue
  • Allow a user to convert from WAV to MP3
  • Allow a user to edit ID3 tag information for v1.0 / v1.1 ID3 tags
  • Save all track list information in XAML where it could also be validated
  • Allow a 2nd PC to control what was played on another PC, like a remote control.

So that was the requirements, and what I came up with was the ReMp3 project. It did fairly well overall, and I was quite happy with it. I ended up getting 1st place prize and being awarded an award by the British Computer Society.

res.png

It looked like the figure shown above here. There were 2 applications a server and a client. And is made use of host of .NET technologies such as Threading, Remoting, DataAcess (ADO .NET), Custom Controls, XML Parsing, Patterns, and Pinging.

Server App

The server app shown below, consisted of 6 main tabs, which were as follows:

  • Home
  • Media Player
  • Mp3 Editor
  • Media Library
  • CD-Ripper
  • WAV to MP3

re.png

Ill now show a screen shotof each of those controls

Media Player

For this control I used the Microsoft Media player, and wrote a wrapper around it, to carry out track lists, drag and drop, reordering of tracklist. One point was that a user could consruct a tracklist of any items on their network, and save that tracklist. As such I had to 1st Ping the host to make sure the tracks read from the saved tracklist, could still be found.

re1.png

MP3 Editor Control

This control was really about byte frigging, as the ID3 information is part of the MP3 file, so it all about maniupulating bytes within the MP3 file.

re31.png

Media Library Control

This is fairly straight forward ADO .NET stuff, except that I threaded all this recursive folder scanning, to free up the UI.re2.png

CD Ripper Control

Although id like to take the credit for this one, the code was mainly sourced at codeproject

re4.png

WAV to MP3 Control

Although id like to take the credit for this one, the code was mainly sourced at codeproject

re5.png

Client App

The client app shown below, consisted of 2 main tabs, which were as follows:

  • Track List
  • Media Library

Track List

This used .NET remoting to call methods on the Server form. It also had to be threaded to allow the server to block under certain conditions where the Client had to block waiting on the server. For instance when the current playing track changes is not a function of the Client but rather the Server, so the Client had to wait for the Server to notify it of a change.

This also used some unmanaged P/Invoke calls to obtain a list of network PCs, that a server could be picked from.

cli1.png

cli2.png

Media Library

The same as the Server app

AutoDiagrammer : My Reflector Addin, Current Work, Significant Projects (Shareable)

AutoDiagrammer : My Reflector Addin

At the beginning of March 2007, i published an article at codeproject about drawing a class diagram using reflection. This article is available here.

The thing being, as more and more people looked at it, they all wanted it to be available as an addin for Lutz Roeder C# De-Compiler which is free and available here.

So finally I gave in, and had a go at getting it to work as a reflector addin, I think i’ve now got there with v1.9 of AutoDiagrammer, which is available right now at the AutoDiagrammer auto update link.

reflect1.png

Ive also kept most of the stand alone application features such as :

  • Zoomable window
  • Printing
  • Customization of what is shown on the diagram
  • Save to image

reflect2.png

I have also now included any associations as a Tooltip, so when there are a lot of classes with a lot of lines going everywhere, simply point the mouse at a class, and see what it tells you.

reflect3.png

I’m just waiting for the codeproject staff to update the article, and then ill be giving Lutz the Addin for official release at his CodePlex site. And then im sure there will be pleny of folk that will have some more suggestions….

LINQ

DLINQ Gotchas

I have just written a new codeproject article about DLINQ using the May 2006 CTP and have stumbled on a few things, that may interest some folk.

Im aware (and have even downloaded the Virtual PC version of) Visual Studio “Orcas”, which now has May 2007 CTP LINQ stuff included. So these gotchas may no longer exist. But ill list them anyway

In my article I am dealing with a Winforms app, so am using a DataGridView to show the results of any queries. I only came across 2 things really:

I am obviously dealing with a Winforms app here, so am using a DataGridView to show the results of any queries. I only came across 2 things really:

  1. When trying to bind the results of a DLINQ query to the DataGridView I had to use the undocumented ToBindingList() on the end of a DLINQ query to be abe to set it as the datasource for the DataGridView
  2. Normally a DataGridView allows its bound contents to be sorted using a column click. Attempting this with DLINQ query bound to the DataGridView , causes an Exception “DataGridView control cannot be sorted if it is bound to an IBlindingList that does support sorting”

The 1st one is fair enough once you know about it.

The 2nd point, Mmmm thats bad. So I had a hunt about and found this article:

Sortable
bindinglist and DLinq
which kind of says that in the May 2006 LINQ CTP version of LINQ there is limited binding support, and its all going to get better in future. So I guess well just have to wait for Visual Studio Orcas to be released officially.