score:1
list<user> users = new list<user>();
users.add(new user() { siteid = 0, ismod = 1, modlimit = 3 });
users.add(new user() { siteid = 1, ismod = null, modlimit = 2 });
users.add(new user() { siteid = 1, ismod = 1, modlimit = 2 });
users.add(new user() { siteid = 1, ismod = 1, modlimit = 2 });
var innerselect = users
.where(o => o.ismod != null && o.ismod > 0)
.groupby(o => o.siteid)
.select(o => new user
{
siteid = o.key,
counter = o.count()
})
.tolist();
var result = (from u in users
join s in innerselect on u.siteid equals s.siteid
where u.siteid == 1
select new
{
u.modlimit,
numberofmods = s.counter
})
.distinct()
.tolist();
Source: stackoverflow.com
Related Query
- LINQ Dynamic Query with group by and string variable
- Group by year and month with given date range using Lambda or LINQ Query
- LINQ to Entities query for count and group by with join on 2 tables
- LINQ SQL Query with a range variable and a constant
- Linq Query With Entities and Group By
- LINQ-Entities Group By With Range Variable Query
- Casting to a derived type in a LINQ to Entities query with Table Per Hierarchy inheritance
- Group by variable integer range using Linq
- Entity Framework - Linq query with order by and group by
- LINQ Query with GROUP and SUM
- Simple sql to Linq query with group by and aggregate functions
- Translating query with GROUP BY and COUNT to Linq
- LINQ query with GROUP BY and Count(*) into Anonymous Type
- Problem with LINQ to Entities query using Sum on child object property
- Linq to entities - SQL Query - Where list contains object with 2 properties (or more)
- How to write a LINQ to Entities query with List in a "WHERE" condition
- How can I create a dynamic LINQ query in C# with possible multiple group by clauses?
- Linq query Group By with contains
- Optimize/rewrite LINQ query with GROUP BY and COUNT
- LINQ join query with relational entities
- LINQ to Entities query to flatten results and select and group desired information
- LINQ to XML : A query body must end with a select clause or a group clause
- Calculate difference from previous item in a group with (single) LINQ query
- pass a linq query with group by to view [errors out]
- LINQ Query with Array input and variable Where Statements - Advice
- Linq to Entities group query giving list of results in each group
- Linq query with GROUP BY on multiple fields, SUM and COUNT
- LINQ query to get all entities with member of specified type
- Linq to Entities simple group query
- LINQ query on entities with join returning items by category
More Query from same tag
- LINQ query string[] group by multiple anonymous columns
- Arithmetic calculation using Linq.Expressions yields different results on 32 vs 64bit
- Linq Intermediate Object in method chain for Where and Select?
- Adding WHERE to a Simple LINQ Query returns zero results (but shouldn't)
- How do I do a left outer join with Dynamic Linq?
- Using Find() with inheritance in entity frameowrk
- SQL to Linq query with multiple left outer joins
- Trying to join two tables using LINQ, nothing is showing up
- Convert SQL sub query to LINQ in C#
- C# Linq Join Issue
- Code practice to handle empty result set in Linq to custom list
- Get XML nodes attributes and set as properties of List<myType>?
- Linq IList<T> hide data and bind to gridview
- How to get input value of dynamically added textboxes
- How to check list has all array items?
- Concatenate rows based on row comparisons using LINQ
- C# Linq Find all indexes of item in List<int> within another List<int>
- How to make the following join?
- LINQ query returning null when comparing elements in two lists
- Check number of one list in another list
- How to use generic list in place of dataset/datable in asp.net?
- Compare and merge two List<T> into new List<T>
- How to validate Linq join query?
- LINQ: join based on table name
- Cannot convert List to IEnumerable when combining 2 generic lists MVC C#
- Handling Next Record nullable reference Controller Code to pass to viewbag
- More than 2 tables JOIN in LINQ, scope issue
- how to take desired value from the multiple same elements in the xml by using LInq c#
- Linq: Group List of Dictionary by multiple properties and Form a List
- Linq Statement between IList and datatable