Here is the LINQ format in C# from your SQL query.
var query = from t in dbContext.User_Tbl
join f in dbContext.Chart_Rest_Tbl.Select(x => x.ChartNo).Distinct() on t.UserNO equals f
join s in dbContext.Chart_Rest_Tbl.GroupBy(x => x.ChartNo)
.Select(g => new { ChartNO = g.Key, TotalDays = g.Sum(x => x.Days) })
on f equals s.ChartNO
select new
{
UserNO = t.UserNO,
UserName = t.UserName,
TotalDays = s.TotalDays
};
var result = query.Distinct().ToList();
To modify or further reference, you can try the below tools to convert your SQL query to LINQ format in C#:
LINQPad - The .NET Programmer's Playground[
^]
Home page - Linqer[
^]