E10.0.704: BPM C# Runtime error with query statement

The physical table you are referencing is actually a view that Epicor creates so that the UD fields show as part of the table.  This view has the UD fields in it so referencing them directly works fine.

The Temporary tables are built by the program and it doesn't know anything about the UD fields at compile time.  Only at run-time does the table["UDField"] referencing get checked.  That is why we don't find out about spelling mistakes in field names until you run the program.

Jim Kinneman
Encompass Solutions, Inc.
From what I can see through various stackoverflow & MSDN post, LINQ doesn't like the section:

where ttOrderHed_Row["OrderType_c"] == "Machine" 

from the following code snippet:

var ttOrderHed_xRow = 
      (from ttOrderHed_Row in ttOrderHed
       where ttOrderHed_Row["OrderType_c"] == "Machine" 
       select ttOrderHed_Row).FirstOrDefault();

From what I understand LINQ converts to SQL and it is during this conversion that the program bombs out which explains while it compiles and saves, but fails when the BPM is called. 

I am struggling to understand how I can get this in a format that C# can deal with. 


How is it failing, are you getting an error message when it is triggered?

From: "bbutler@... [vantage]" <vantage@yahoogroups.com>
To: vantage@yahoogroups.com
Sent: Thursday, September 10, 2015 7:22 AM
Subject: [Vantage] E10.0.704: BPM C# Runtime error with query statement



From what I can see through various stackoverflow & MSDN post, LINQ doesn’t like the section:


where ttOrderHed_Row[“OrderType_c”] == “Machine” 

from the following code snippet:

var ttOrderHed_xRow = 
      (from ttOrderHed_Row in ttOrderHed
       where ttOrderHed_Row[“OrderType_c”] == “Machine” 
       select ttOrderHed_Row).FirstOrDefault();

From what I understand LINQ converts to SQL and it is during this conversion that the program bombs out which explains while it compiles and saves, but fails when the BPM is called. 

I am struggling to understand how I can get this in a format that C# can deal with. 






Try and use the UDField<String>("MyField",false) accessor


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Thu, Sep 10, 2015 at 8:00 AM, Ted Koch tkoch77@... [vantage] <vantage@yahoogroups.com> wrote:

Â
<div>
  
  
  <p></p><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px;">How is it failing, are you getting an error message when it is triggered?<br><div><span></span></div>  <div style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px;"> <div style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"> <div dir="ltr"> <hr size="1">  <font face="Arial" size="2"> <b><span style="font-weight:bold;">From:</span></b> &quot;<a rel="nofollow" target="_blank" href="mailto:bbutler@...">bbutler@...</a> [vantage]&quot; &lt;<a rel="nofollow" target="_blank" href="mailto:vantage@yahoogroups.com">vantage@yahoogroups.com</a>&gt;<br> <b><span style="font-weight:bold;">To:</span></b> <a rel="nofollow" target="_blank" href="mailto:vantage@yahoogroups.com">vantage@yahoogroups.com</a> <br> <b><span style="font-weight:bold;">Sent:</span></b> Thursday, September 10, 2015 7:22 AM<br> <b><span style="font-weight:bold;">Subject:</span></b> [Vantage] E10.0.704: BPM C# Runtime error with query statement<br> </font> </div><span class="ygrps-yiv-1750003375"> <div><br><div>



From what I can see through various stackoverflow & MSDN post, LINQ doesn't like the section:


where ttOrderHed_Row["OrderType_c"] == "Machine"Â

from the following code snippet:

var ttOrderHed_xRow =Â
   (from ttOrderHed_Row in ttOrderHed
    where ttOrderHed_Row["OrderType_c"] == "Machine"Â
    select ttOrderHed_Row).FirstOrDefault();

From what I understand LINQ converts to SQL and it is during this conversion that the program bombs out which explains while it compiles and saves, but fails when the BPM is called.Â

I am struggling to understand how I can get this in a format that C# can deal with.Â






</div>
 


<div style="color:#fff;min-height:0;"></div>

Just make it look like this, and you won't have that issue as long as OrderType_C is a string.


var ttOrderHed_xRow = 

      (from ttOrderHed_Row in ttOrderHed

       where ttOrderHed_Row.OrderType_c == "Machine" 

       select ttOrderHed_Row).FirstOrDefault();

you can't address the ud fields directly in the ttTables.


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Fri, Sep 11, 2015 at 9:11 AM, amathis@... [vantage] <vantage@yahoogroups.com> wrote:

Â
<div>
  
  
  <p></p><p>Just make it look like this, and you won&#39;t have that issue as long as OrderType_C is a string.</p><span class="ygrps-yiv-226945715"><p><br></p><div><p style="background:white;"><span style="color:black;">var ttOrderHed_xRow =Â </span></p></div><div><p style="background:white;"><span style="color:black;">Â  Â  Â  (from ttOrderHed_Row in ttOrderHed</span></p></div></span><div><p style="background:white;"><span style="color:black;">Â  Â  Â  Â where ttOrderHed_Row.OrderType_c == &quot;Machine&quot;Â </span></p></div><div><p style="background:white;"><span style="color:black;">Â  Â  Â  Â select ttOrderHed_Row).FirstOrDefault();</span><br></p></div><p></p>

</div>
 


<div style="color:#fff;min-height:0;"></div>

That was my first iteration,and tried again last night.   I assume this doesn't work because it is an extended field.

Thanks for the suggestion. 


Sent from my Verizon Wireless 4G LTE smartphone


-------- Original message --------
From: "amathis@... [vantage]" <vantage@yahoogroups.com>
Date: 09/11/2015 8:13 AM (GMT-06:00)
To: vantage@yahoogroups.com
Subject: [Vantage] Re: E10.0.704: BPM C# Runtime error with query statement

 

Just make it look like this, and you won't have that issue as long as OrderType_C is a string.


var ttOrderHed_xRow = 

      (from ttOrderHed_Row in ttOrderHed

       where ttOrderHed_Row.OrderType_c == "Machine" 

       select ttOrderHed_Row).FirstOrDefault();

try casting the field first
(string)Â ttOrderHed_Row["OrderType_c"] == "Machine"Â


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Fri, Sep 11, 2015 at 9:16 AM, 'Butler, Bruce' bbutler@... [vantage] <vantage@yahoogroups.com> wrote:

Â
<div>
  
  
  <p><u></u>

That was my first iteration,and tried again last night. Â I assume this doesn't work because it is an extended field.

Thanks for the suggestion.Â


Sent from my Verizon Wireless 4G LTE smartphone


-------- Original message --------
From: "amathis@... [vantage]" <vantage@yahoogroups.com>
Date: 09/11/2015 8:13 AM (GMT-06:00)
To: vantage@yahoogroups.com
Subject: [Vantage] Re: E10.0.704: BPM C# Runtime error with query statement

Â

Just make it look like this, and you won't have that issue as long as OrderType_C is a string.


var ttOrderHed_xRow =Â

   (from ttOrderHed_Row in ttOrderHed

    where ttOrderHed_Row.OrderType_c == "Machine"Â

    select ttOrderHed_Row).FirstOrDefault();

</div>
 


<div style="color:#fff;min-height:0;"></div>

I didn't see it was a UD field, my fault. Yeah I'd try to cast the right side and see if LINQ is ok with that on E10's side.
You might combine that with string.compare.

string.compare((string)ttJobHead_xRow["ShortChar02"], "Education", true) == 0

Jim Kinneman
Encompass Solutions, Inc.