LINQPad 4 for testing BPM queries?

@erikj if no one has mentioned it lately, we appreciate your presence and input here on the forum, as we do all epicor insiders, consultants and knowledgeable users!

[System.Data.Entity.DbFunction(“EpicorDB”, “ConvertToInt”)]

public static int ConvertToInt(string val)
        return Int32.TryParse(val, out Int32 result) ? result : default;

Here is how to format c# code on the forum

1 Like

Are you saying we can create our own conversion functions(As long as we add it as a reference)? Or are you just pointing out what the ErpEFFFunction does?

I was just pointing out what the ErpEFFunction does (which was nothing magic). These functions are baked into the Erp model (which is what the docs said to do) and I’m not sure EF will recognize functions declared outside the model. But I’ll play with it and see what happens.

I was unsuccessful in my attempt create my own functions that worked. I did find a resource, which may be useful for others if they need to know what .Net methods will work out of the box.

However, there doesn’t seem to be any methods that convert decimals to integers. Since the UD tables don’t have integer fields, projecting the Decimal fields to an Integer field in an anonymous type is pretty ugly and not intuitive.


versus something simple like


And just to be clear, this concerns Linq to Entities. Once the records are in memory, Linq to Objects takes over and type conversions are not an issue.

I can see about getting a function added to the model for converting decimals to ints. But it probably wouldn’t be backported very far. What version are you on? patching this weekend to

I second those remarks from Chris. Thanks for your input Erik.

1 Like

A smart guy in our Birmingham, UK office reminded me that decimal has an intrinsic cast to int, which is supported by EF. Strings can’t be cast to ints, which is why we have the helper functions. But this should work…

var q = Db.UD13.Select(s =>

        MyNumber = (int)s.Number01

By golly you’re right. I thought I tried that but apparently not. Much simpler. I can’t believe that I didn’t find that in all my googling.

I’ll share this link for valid numeric casts:

Hi Caleb,

I’m using Epicor 10.2.200 and I’m trying to mock up and instantiate an instance of the ErpContext. I have all but the Epicor.Data.Provider reference. I tried locating it inside the Assemblies folder on the machine Epicor is installed on, but no luck.

Do you know where else I can find it? I keep getting that " *o Entity Framework provider found for the ADO.NET provider with invariant name ‘EpiProvider’." error message like you were getting.



So this was for 10.2.100 maybe .200

It might be instead of EpiProviderRegistration - It may be EpiProviderRegistrator ( i may even have it incorrect in the article )

// Enable for 10.2 Only: EpiProviderRegistration.Register();
for the following:
// Enable for 10.2 Only: EpiProviderRegistrator.Register();
1 Like

I think I just got it.

Looks like it accepts:

That ADO error went away once I added this in.


1 Like

Also check the LinkedIn Article :slight_smile: I need to convert it to Markdown and paste here.


Have you ever had the need to instantiate a quote service (shown below)?

Erp.Contracts.QuoteSvcContract quote = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.QuoteSvcContract>(context);

It keeps giving me the error “Unable to find assembly for contract Erp.Contracts.QuoteSvcContract”.

The context instantiates fine, why wouldn’t the service?

Press F4 and you have to add the Assemblies in.

In your case Erp.Contracts.QuoteSvcContract preferrably from within your Epicor Client Directory.

I didn’t notice if you used LINQPad with the OData services? It works kind of nice :wink:

1 Like

for those starting out with Linq. If you have not seen 101 LINQ Samples here’s a link (pardon the pun)


getting error message saying my the provider did not return a provider manifest instance

Try using this updated one for 10.2.300+ I need to update it on repo, had to reference diff .net assemblies for EF6 I used the NuGet feature in LINQPad I wonder if it sticks if I shared the updated file:

Epicor_10_LINQPad_Starter - Copy.linq (3.2 KB)