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.
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.
Source: stackoverflow.com
Related Articles
- How can I convert this SQL Query into LINQ (OVER (PARTITION BY Date))
- Convert linq query expression with multiple froms into extension method syntax
- Convert SQL into Linq query
- How to get SQL query into LINQ form in C# code
- Convert double for-loop into a linq query
- Convert a two-step LINQ query into a single LET query?
- How to convert this complex SQL Query with Subqueries into LINQ
- convert linq to object query to sql query (no linq to sql code or datacontext)
- Convert piece of code into LINQ (short syntax)
- How to convert leftouterjoin query into LINQ
- Convert SQL query in LINQ query and move results into new datatable
- How can I code numerous MIN functions into one LINQ to DataSet query
- Convert LINQ query to string, send to remote server to parse into an expression using Roslyn?
- Convert Linq to Sql query into better sql
- Can I can convert this C# code into some Linq code?
- Convert a sql query with a subquery into a linq statement
- How to convert sql inner join query into linq to sql query and convert into list
- How can I convert Linq to Entities Query into expression tree?
- Convert SQL query into LINQ - DateDiff function
- How to Convert this Linq Query into Lambda Expression
- Convert Sql Query of Last 50 minutes record into Linq Query
- convert an sql query into linq to entities method based
- Convert sql query into linq getting error in converting date
- How to convert linq query into a list keyvaluepair
- Can anyone convert this SQL query into a C# Linq statement?
- How can i convert this code snippet into LINQ format?
- Convert SQL raw query into Linq
- Convert this SQL query into Linq
- How do I convert this SQL inner join query into LINQ syntax?
- Convert a SQL query into a Linq to SQL instruction
- How to group linq query by dynamic items
- Why is this Linq to XML query not working
- Custom properties and lambda expressions
- C# Linq Select Rows Where ID Equals ID in CSV
- Can PredicateBuilder generate predicates that span multiple tables?
- Precompile Lambda Expression Tree conversions as constants?
- Order IEnumerable<T> object based on Dictionary
- C# Method run time increases the more it is called
- Lambda overload for Skip/Take Missing
- Recursive call to compare object properties
- How can I retrieve an object from a generic list based on the value of two of that object's members?
- LINQ - Comparing a List of strings against a colon separated field
- Read the XML using Linq and check if the elements exist
- WeakEventHandler with LINQ and delegate constraint
- Sorting in Linq by constructing the linq statement as a string?
- VB.NET LINQ WHERE query collection with various keys throws KeyNotFoundException
- LINQ: check whether two list are the same
- linq change the value of a result set
- Extension method returning lambda expression through compare
- group by base on 2 element