score:2
Accepted answer
var no_ctivities = db.activities
.join(
db.enrollments,
ac => ac.activityid,
en => en.activityid,
(enr, act) => new { en = enr, ac = act })
.join(
db.participants.where(pr => pr.participantid == id),
en => en.ac.participantid,
prt => prt.participantid,
(enr, prt) => new { enr.ac.posttestscore1, enr.ac.posttestscore2, enr.ac.activityid, enr.ac.attendfirstday, enr.ac.attendsecondday })
.select(c => new
{
c.activityid,
c.posttestscore1,
c.posttestscore2,
c.attendfirstday,
c.attendsecondday
}).count();
score:2
var query = from a1 in activities
join e1 in enrollments on a1.activityid equals e1.activityid
join p1 in participants on e1.participantid equals p1.participantid
where e1.participantid= 2883
group new { e1, a1 }
by new { e1.posttestscore1, a1.activityid } into g
select new
{
activityid = g.key.activityid,
posttestscore1 = g.key.posttestscore1,
no_activities = g.count()
};
Source: stackoverflow.com
Related Query
- Convert SQL raw query into Linq
- How can I convert this SQL Query into LINQ (OVER (PARTITION BY Date))
- Convert SQL into Linq query
- How to convert this complex SQL Query with Subqueries into LINQ
- Convert SQL query in LINQ query and move results into new datatable
- Convert Linq to Sql query into better sql
- 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
- Convert SQL query into LINQ - DateDiff function
- 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
- Can anyone convert this SQL query into a C# Linq statement?
- 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
- Convert a given SQL query into linq for Entity Framework
- How to convert Sql Datetime query into Linq
- C# How to convert SQL into a LINQ query
- How to convert this sql query into linq query. I am stuck at the group by and sum part
- Convert SQL query into Linq expression
- How to convert sql query into Linq to entities?
- How to convert this query string into LINQ to SQL query?
- Convert SUM / CASE WHEN / GROUP BY SQL query into LINQ
- how to convert a sql query into linq LEFT OUTER JOIN
- C# convert sql query into EF dbcontext linq to entities query
- convert SQL query with multiple join on multiple tables using group by on multiple columns and with aggregate function into LINQ
- How to convert SQL Query into LinQ
- How can i convert a SQL query into LINQ using group and having?
- need to convert sql join query with count into linq and pass it to view
More Query from same tag
- How to compare int with string in linq where clause
- linq order by from second table count
- Convert list of ints to sql binary(8) list
- Not expected result when use Linq Select
- linq with entity framework - translate from SQL
- Unable to retrieve a value from JSON, getting 'Cannot cast Newtonsoft.Json.Linq.JArray to Newtonsoft.Json.Linq.JToken.' exception
- how to fix the following issue in linq?
- Joining multiple tables using Entity Framework
- Adding a where/order by clause to an IQueryable
- LINQ instead of for loop in wpf?
- System.InvalidCastException: Unable to cast object of type 'System.Linq.GroupedEnumerable
- Get each item from a list and compare it with a different one
- Linq GroupBy to switch dimensions
- Getting a list of users with their assigned role in Identity 2
- Using LINQ to iterate through a database and generate a generic XML layout of schema + data
- Simplify Lambda to Sum Sibling Tag Values using LINQ to XML
- Sequence contains no elements - no info in stack trace
- How do I get previous key from SortedDictionary?
- cannot convert mysql query to linq statement
- Remove parents from list
- Linq: Sum of int
- Linq to populate values of a class
- How can I perform this type of JOIN in Entity framework with LINQ
- Construct LambdaExpression for nested property from string
- Is there a LINQ way to turn 2 line items into N based on quantity?
- Is it possible to use Linq to get a total count of items in a list of lists?
- Can you set a property in a linq query before selecting the item?
- Dynamic LINQ DateTime Comparison String Building - Linq To Entities
- Is it efficient to use LINQ to parse strings?
- @HTML.Grid LINQ using if condition in HTML itself