(E10) C# Linq: Linking extending fields (_UD Tables)

From within Methods Directives (PreProcess BPM), I am trying to pull the order number for orders that have a user defined field, OrderType_c == "Machine" for the current record being modified.  The system is not recognizing the ttOrderHed_UD table.  Do I have to treat the _UD tables differently somehow?  


Below is an example of the code:


Erp.Tables.OrderHed OrderHed;

Erp.Tables.OrderHed_UD OrderHed_UD;

Erp.Tables.OrderDtl OrderDtl;


string MachineOrder = 

from oh in ttOrderHed

join oh_u in ttOrderHed_UD

on oh.SysRowID equals oh_u.ForeignSysRowID 

where oh_u.OrderType_c == "Machine"

select oh.OrderNum;


    

What version of Epicor are you running?  In 10.0.700.x and up you don't have to join the UD table to the base table.  The fields are added when you regenerate the data model.  I also would try something like .FirstOrDefault at the end of statement:


string MachineOrder = 

from oh in ttOrderHed

   where oh["OrderType_c"] == "Machine"

select oh.OrderNum.FirstOrDefault();