I have a simple question. I have a UD Method that I am using in a configurator. I need to query a UD table to get a value but I can’t seem to get the namespace right. I have this:
var xyz= (from x in Db.UD14
where x.DtRipPerStick == "11"
select x).FirstOrDefault();
It doesn’t like Db. or Erp. or Ice. What am i missing to query a UD table?
If it’s an extended field on that table (I think it is), you’ll need to reference it in one a few ways.
You could try x.UDField<string>("DtRipPerStick") == "11";
or x["DtRipPerStick"] == "11"
This will work the way you have it written, assuming this is a server method and that the column name is correct (missing _c possibly?)
The columns are not the problem. I cant seem to reference the table. Tells me there is no UD14 (or any UD table) in Db. Namespace.
BPM no problem. No UD method I cant get it to work.
Can you post a screen shot of your method - like this shown below? This accesses UD14 and a UD column just fine (using same code). I was always under the impression _c was required on UD column names when creating but sounds like you may have an issue before that. Can you post the error as well?
One other thing that I thought of is that sometimes errors you see in UD methods might not be directly related to the code you are checking the syntax for. It could be that another method has an error or in the calling of a different method.
It looks like the table is different than the rest of the tables. If i use Linqpad i see this:

But i can’t seem to reference that table. I have this:
var row = Db.UD14_UD.Where(u => u.DtRipPerStick_c == 11).FirstOrDefault();
I get this error:

I get the same message if i try
var row = Db.UD14_UDs.Where(u => u.DtRipPerStick_c == 11).FirstOrDefault();
I don’t get that same error if i do this but i get a different error saying it can’t find DtRipPerStick_c:
var row = Db.UD14.Where(u => u.DtRipPerStick_c == 11).FirstOrDefault();

Are you able to type “x.” And then hit ctrl+space bar to see what fields and method are available on your Db.UD14 query? Assuming you’re using query syntax
Even backing up a step, do the same with Db to see what it can see
To answer your question, nothing shows.
I can’t say i understand how Epicor creates tables and joins them together. I don’t understand why I have a UD14_UD table and no UD14 table or why the UD14_UD table has a foreign key to Ice.UD14.
Irregardless I have found the issue with what i was doing. When I run the queries in LinqPad, it shows the columns like this.

Then i queried in SSMS and saw a difference.

I was using a capital ‘D’ because that is what i was seeing in LinqPad. I changed it to lowercase and all is well in the world.
var row = Db.UD14.Where(u => u.Key1 == "Default").FirstOrDefault();
return Convert.ToString(row.dtRipPerStick_c);
2 Likes