score:1

from t in Temp_Nurse_Fill_RequestNumbers 
group by t.ShiftName, t.date
into g 
select new 
{
   Date = g.date,
   Score = (from tt in g select tt.Score).max
   IsPreferred = 1
};

score:0

You can use a tool called LINQPad.

Tired of querying in antiquated SQL? Well, you don't have to! LINQPad lets you interactively query databases in a modern query language: LINQ. Kiss goodbye to SQL Management Studio! ... LINQPad is also a great way to learn LINQ: it comes loaded with 500 examples from the book, C# 4.0 in a Nutshell. There's no better way to experience the coolness of LINQ and functional programming.

LINQPad Website

hope this helps

score:1

Hmm, how about something like this (this is C#, I presume it is trivial to convert)

temps
    .GroupBy(x => new {x.ShiftName, x.Date})
    .Select(g => new TempNurseProjection
        {
            Date = g.Key.Date,
            ShiftName = g.Key.ShiftName,
            MaxScore = g.Max(q => q.Score),
            IsPreferred = true
        });

score:1

Just for convenience

tems.
    GroupBy(Function(x) New With { x.ShiftName, x.Date }).
    Select(Function(g) New TempNurseProjection With {
        .Date = g.Key.Date,
        .ShiftName = g.Key.ShiftName,
        .MaxScore = g.Max(Function(q) q.Score),
        .IsPreferred = True
    })

EDIT

Sorry didn't noticed that the final projection is not anonymous but named type.


Related Articles