Function Custom C# code giving error when trying to use linq query to retrieve customer name

I’m trying to make a function that will take a input value of the customer number and return the customer name here is my code.


and I keep getting these errors .
There is at least one compilation error.

library.db.interface.cs(13,20): error CS0118: ‘Customer’ is a namespace but is used like a type
library.db.cs(28,27): error CS0118: ‘Customer’ is a namespace but is used like a type
library.db.cs(28,49): error CS0266: Cannot implicitly convert type ‘System.Data.Entity.Core.Objects.ObjectSet<Erp.Tables.Customer>’ to ‘System.Linq.IQueryable<EFx.Customer>’. An explicit conversion exists (are you missing a cast?)
library.db.tracker.cs(24,44): error CS0118: ‘Customer’ is a namespace but is used like a type

I’m not sure what is causing it.

You have customer included in your tables and your function setup for DB reads?

Yes its in the references for the tables is there anywhere else I need to add it.

send screenshots of your tabs in Function Maintenance.

1 Like

These are the only tabs that I have filled in everything else is empty

Make sure of this as well:

You could always try something like this:

CustName = Db.Customer.Where(x=>x.CustNum==CustNumber).Select(x=>x.Name).FirstOrDefault();

The main tab do you have your function setup for DB read go back to the detail tab.

Yes I did and I think I found that the issue was that the library name was also called Customer so it caused a issue in the C# code to where the code was thinking I was calling the library called Customer and not the table. I made a new library with a different name and it does not give any errors now.

4 Likes