[ Tools / Download ] Epicor LINQPad Starter Kit

Download: Epicor_10_LINQPad_Starter.linq (3.9 KB)

Intro

Have you always wanted to make use of LINQPad for BPM Prototyping, but got stuck in configuration limbo and weren’t quite sure how to reference assemblies to make use of the ErpContext? If yes, then this quick-starter guide is for you.

I am going to assume you know what LINQPad is and what benefit’s you get with the professional version and if not then visit https://www.linqpad.net/ for more information.

Screenshots

Download Starter File

Download: Epicor_10_LINQPad_Starter.linq (3.9 KB)

Credits

When Epicor 10.1.400 was released @Edge sent me his . linq files which required little to no configuration and it makes use of the web.config, reads the connection details and with it, allows you to use the ErpContext() or IceContext() - you know that fancy Db object in Method and Data Directives, yes that one. Thank’s Stephen!

Configuration

Once you download the Epicor_10_LINQPad_Starter.linq file and open it.

Press F4 it will bring up a dialog where you can point to your Server’s Assemblies. Fix the ones in RED, shown below are the typical 10.1.500.x paths for the Assembly Locations.

The Starter file includes common used Namespaces:

In the LINQPad Window point to your web.config file:

You should be all set, it was that easy. You don’t need a Connection! Remember it reads it from your web.config

Few Gotchas

  1. If you are having connection issue(s) make sure that your web.config file isn’t pointing to Database Server (local) which is usually seen when the SQL Database is on the same machine as the App Server, common in development environments. Make sure you change it to the actual server name instead.

Epicor_LINQPad_5_9

  1. One limitation is that you can’t use ttTables, the idea is that you use this with actual tables such as Db.Part and prototype, debug and analyze your query. Once you are confident that it’s all good to go - you make some minor tweaks and paste it into a BPM.

  2. When you want to use Business Objects such as Ice.Core.Session etc, make sure you add the Assembly to your references - typically you will add BO .dll’s from your Local Epicor Client Folder

  3. Can’t use LockHint, unless you probably specify an additional assembly.

  4. For Epicor 10.2 make sure you enable the commented-out line EpiProviderRegistrator.Register();

Have Fun

Overall, you can use Business Object’s, Query Syntax or Method Syntax . Prototyping in LINQPad has often saved me from various headaches in the past. If you have the Paid LINQPad Version, you get to enjoy some additional IntelliSense.

Wait Theres More Reminder

If you do use the BOs make sure you Press F4 to include the Assemblies!

15 Likes

@hkeric.wci, figured I’d give this a try since I’m working on a new BPM. I’m on E10.2.200.8 and I’m running into an error on the line:

EpiProviderRegistrator.Register();

InvalidOperationException: The default DbConfiguration instance was used by the Entity Framework before an attempt was made to set an instance of ‘EpiConfiguration’. The ‘EpiConfiguration’ instance must be set at application start before using any Entity Framework features or must be registered in the application’s config file. See Code-based configuration - EF6 | Microsoft Learn for more information.

Thoughts?

Never mind; I added EntityFramework.SqlServer.dll and it worked!

Thanks!

Yes I had to get new System packages with nuget, try this starter-kit for EF6

1 Like

Hi All,

I keep getting this error.

TypeInitializationException: The type initializer for 'Erp.ErpContext' threw an exception.

I have read the other threads which state change the data source in the web.config file. I did this but no further forward.

Not sure – my most recent one looks like this:

I had to add in a reference to EntityFramework to get it to work.

Getting error on this:

		   boPriceListInquiry = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.PriceListInquirySvcContract>(Db);		

Value cannot be null.
Parameter name: Operation

Any ideas???

My above screenshot may be misleading as it shows me using something similar - I later replaced it.


Since LINQPad is basically considered a “client” and you are not on the Server, you have to use WCFServiceSupport and first create a Session, the reason you get that weird error is probably because you dont have a valid session.

Also see the screenshot all the way-up (first one).

https://www.epiusers.help/search?q=wcfservice

Solved this by using a different way to look at the data, but thank you! I did have a proper session setup thanks to your awesome example!

	// Client Init
	using (var session = new Ice.Core.Session("manager","manager",Ice.Core.Session.LicenseType.EnterpriseProcessing,@"D:\Epicor\ERP10\LocalClients\EpicorERPPilot\config\EpicorERPPilot.sysconfig"))
	using (var pli = WCFServiceSupport.CreateImpl<Erp.Proxy.BO.PriceListInquiryImpl>(session, Erp.Proxy.BO.PriceListInquiryImpl.UriPath))
1 Like

I am using LinqPad6 and for some reason it cannot see my connectionString in my webconfig. I’ve double and triple checked my assemblies and their locations as well as the web.config. Not sure why it’s failing here.

image