BPM C# Linq Expression Help

Hi

var partBin = Db.PartBin.OrderBy(row => row.BinNum).FirstOrDefault(row => row.Company == Session.CompanyID && row.PartNum == moveRequest.PartNum && row.WarehouseCode == “WH” && row.OnhandQty > 0 ;);

I have this in a BPM - I would like to extend this SELECT query slightly, to only look for Bins where RIGHT(BinNum, 1) DOES NOT equal “C”.

Can somebody modify it for me to do this?

I having considered EndsWith, Substring, Right - but don’t know how to do the != check, and what bits are and aren’t supported.

Many Thanks
Mark

The bellow is using EndsWith. You should test it out. Linq turns the expression into sql and runs it against the database. If it doesn’t have a matching sql command it will throw an exception. It might give you an error.

var partBin = Db.PartBin.OrderBy(row => row.BinNum).FirstOrDefault(row => row.Company == Session.CompanyID && 
row.PartNum == moveRequest.PartNum && 
row.WarehouseCode == “WH” && 
row.OnhandQty > 0 &&
!row.BinNum.EndsWith("C"));
1 Like

Jeremy, thanks so much – that worked perfectly.