Need to modify the below sql query to linq to entities.
SELECT a.*, c.*
FROM bp_user a
INNER JOIN bp_audit_logintime c
ON a.UserName = c.User_Name
INNER JOIN
(
SELECT User_Name, MAX(Login_Time) maxDate
FROM bp_audit_logintime
GROUP BY User_Name
) b ON c.User_Name = b.User_Name AND
c.Login_Time = b.maxDate
we got struck near Inner Join with select sub query......Please help
Loading
Jignesh TrivediPosted Nov 13, 2013, 3:03 AM
Hi,
LINQ query some thing like....
var k = from u in context.bp_user
join c in context.bp_audit_logintime on u.UserName equals c.UserName
join other in (from a in bp_audit_logintime
group a by a.User_Name into g
select new {
UserName = User_Name, MaxTime = g.Max(x=>x.Login_Time)
}) on new { un = c.User_Name , lt = c.Login_Time} equlas new { un = other.UserName , lt = other.MaxTime}
select new { u, c}
try it might have some syntax error
hope this will help you.
lakshmi sowmyaPosted Nov 13, 2013, 4:42 AM