Inside a c# BPM on Erp.Part.Update / Pre-Processing,
I’m getting PartTable does not contain a definition for PartNum.
var part = (from row in Db.Part.With(LockHint.NoLock)
where row.Company == Session.CompanyID
&& row.PartNum == ttPart.PartNum // problem is here somehow
select row)
.FirstOrDefault();
Produces this error: CS1061 ‘PartTable’ does not contain a definition for ‘PartNum’ and no accessible extension method ‘PartNum’ accepting a first argument of type ‘PartTable’ could be found (are you missing a using directive or an assembly reference?)
If I show message with ttPart.PartNum in the BPM it shows the part number so I think it should be available. What am I doing wrong?
Also note that if you do not need the entire part record, that you should be selective about which fields to return. Being selective improves the speed… Example, if you only need the part Description and UOM, you could use THIS:
var ttPartRow = ttPart.Where(P => P.Added() || P.Updated()).FirstOrDefault();
if (ttPartRow != null) {
var part = Db.Part.With(LockHint.NoLock).Where(P =>
P.Company == CompanyID &&
P.PartNum == ttPartRow.PartNum).Select(P=>new {P.PartDescrition,P.IUOM}).FirstOrDefault(); }
if you only need one value, such as the description, you can simplify this even further, and return that one value into a string. In this case, if the part is not found, it will put “NotFound” in the description: