Closed ingezone closed 4 years ago
Too late here, but I think I understand correctly your query:
var queryCondition =
from t1 in Table1
join t3 in Table3 on t1.NameOfProtocol equals t3.NameOfProtocol
join t2 in Table2 on new { t1.IdGroup1, t1.dGroup2 } equals new { t2.IdGroup1, t2.dGroup2 }
where t3.Protocol == "TCP"
group t2 by new { t1.Code } into g
select new
{
g.Key.Code,
Static = g.CountExt(_ => _.Status == 0 ? 1 : (int?)null),
Dinamic = g.CountExt(_ => _.Status == 1 ? 1 : (int?)null),
MaxDinamic = g.Max(_ => _.Status == 1 ? _.Level : (double?)null)
MinStatic = g.Min(_ => _.Status == 0 ? _.Level : (double?)null),
};
var queryNF = from ob in queryCondition
order by ob.Code
select new
{
ob.Code,
Level = ob.Static >= ob.Dinamic ? ob.MinStatic : ob.Static < ob.Dinamic ? ob.MaxDinamic : null
};
var result = queryNF.ToLinqToDB().ToList();
Once again, thank you very much. This works 100% as I need. 👍
URW, closing then.
Hello
You can help me transform my query to use with linq2db.
My query obtains the maximum or minimum value of the LEVEL field, with the following conditions and for that subqueries were resolved, which first returns the following: