ObjectSharp Blogs

You are currently viewing

Dave Lloyd's 2 Cents

A .NET Developer's Perspective


C# Query Syntax

Barry Gervin has a post with some LINQ links that is very useful.

Just to show you how easy it is. Here is the Query Don Box wrote during the key note today. I haven't seen it yet but I am told it's even easier to read in the VB syntax.

This is only the query itself so assume that p is a collection of processes and d is a class associated with a table and columns in the Database.

var query =
   from p in Process.GetProcesses()
   where p.WorkingSet > 4194304
   orderby p.WorkingSet
descending
   Select new 
   
{
      p.ProcessName,
      p.WorkingSet,
      Description = ( from d in db.ProcessDescriptions
                      where d.processName == p.Processname
                      Select d.Description
                    
).FirstOrDefault()
   };

Comments

    No Comments

Leave a Comment

(required) 
(optional)
(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS