i have some table in dataBase. INV,LIB,TRAN_TT1 datatype all field in 3 table are string . i write this code
var m = new MaterialModelContainer();
var list = (from inv in m.INVs
where inv.NEW_QTY == "000000"
join lib in m.LIBs on inv.MESC equals lib.MESC
join tt1 in m.TRAN_TT1 on inv.MESC equals tt1.MESC4
where tt1.TYPE2 == "60" && tt1.QTY == "000000"
select new
{
inv.MESC,
lib.LINE_NO,
lib.UNIT_LINE,
Description = lib.DES + " " + lib.PART_NO,
}).ToList();
table TRAN_TT1 has a ACTD field, i want get max value
i write this code
var m = new MaterialModelContainer();
var list = (from inv in m.INVs
where inv.NEW_QTY == "000000"
join lib in m.LIBs on inv.MESC equals lib.MESC
join tt1 in m.TRAN_TT1 on inv.MESC equals tt1.MESC4
where tt1.TYPE2 == "60" && tt1.QTY == "000000"
select new
{
inv.MESC,
lib.LINE_NO,
lib.UNIT_LINE,
Description = lib.DES + " " + lib.PART_NO,
ACTD= tt1.ACTD.Max()
}).ToList();
but no work,
please help me to get max ACTD field . thanks all
Max is a aggregate function, and the aggregate functions in Linq has the same restrictions like in SQL – if you use aggregate function for one of the column – all other using columns should be also used in aggregate functions or you should use GroupBy by them.
So your sample should be something like: