How to write LINQ query in C# customization

Hello
I am trying to fetch data from UserField table to UD01Form using LINQ query through c# code in script editor. but am getting " The type or namespace name ‘UserFile’ does not exist in the namespace ‘Erp’ (are you missing an assembly reference?) "Error

From what I understand, you can’t use LINQ client side. Probably the easiest way to get that would be create a BAQ and then run a dynamic query call to get the information.

You can use LINQ client side, just not in the same fashion as in a BPM because you do not have direct db context access in client side customization. @Banderson is correct you will need to query for the data as it is not directly accessible in client customization.

For instance this is how I retrieve the added record in a dataset using LINQ.

job.GetNewJobMtl(jobds, "job123", 0);
JobEntryDataSet.JobMtlRow newRow = jobds.JobMtl.OfType<JobEntryDataSet.JobMtlRow>().FirstOrDefault(r => r.RowMod.ToUpper() == "A");
4 Likes

@tkoch
Thank you for your response
I already used BAQ to get the information…But am trying to retrieve through linq code.
Am new to epicor application am finding some difficulties.Can u provide any docs or any resources .so that i can work on whole linq operation.such as creating,updating,deleting data from database table through c# code in customization.Thank you advance.

What is your end goal that you’re trying to use LINQ to achieve?

In Epicor development, you really don’t want to update the database directly. Work through the business objects. https://epicweb.epicor.com has all the documentation required.

5 Likes

@ckrusen
Hello
I have taken UD form, when the form loads i want to retrieve current user group,username,current user Email Address in epitextbox, and remaining all others user Email Address should be retrieve in epicombo box…so that using this field current user can send a email,when user clicks on send Button email should be send to selected user and data should be saved in ud01 table at the same time.To achieve this am trying to use LINQ.
Thank you in advance.
Email