DataPortalException with LinqPad

DataPortalException with LinqPad

Old forum URL: forums.lhotka.net/forums/t/10244.aspx


JasminK posted on Thursday, April 07, 2011

I've referenced my business objects assembly within LinqPad. Of course, I've also referenced DAL assembly (LINQ to SQL) and Csla.dll as well. Apropriate namespaces are also included. Added a connection using typed data context from DAL assembly. So everything should work just fine, right?

Querying against DAL assembly's Linq to Sql classes works great, but querying against my business objects throws 'DataPortalException: DataPortal.Fetch failed (Database name not found in config file (MyDatabase))'

I have to mention that these assemblies work within my application.

I'm a newbie to LinqPad. Any hints?

Post edit:

I've just investigated... do I need some sort of CSLA Data Context Driver in order to query CSLA business objects and can it be downloaded somewhere?

RockfordLhotka replied on Thursday, April 07, 2011

I don't know much about LinqPad - too many tools, too little time...

But this sounds like a simple .NET config issue. The CSLA data helpers use the standard .NET config API from System.Configuration to get values. That means the values come from the config file for the current AppDomain, and that is determined by the program you are running, not by the CSLA assemblies.

If you are running LinqPad, then it owns the AppDomain, and it supplies the config file. So you'll need to find the linqpad.exe.config file in the directory with linqpad.exe - that's what the .NET runtime is looking for.

JasminK replied on Thursday, April 07, 2011

I got it. The bummer with LinqPad is that it's just a simple .exe file so it has no instalation folder or config file. I've added my database connection string in the machine.config file and now it works like a charm :)

 

Thanx Rocky!

RockfordLhotka replied on Thursday, April 07, 2011

You can probably just create a linqpad.exe.config file in the same folder that contains linqpad.exe to make it work.

Joe Albahari replied on Friday, April 08, 2011

> You can probably just create a linqpad.exe.config file in the same folder that contains linqpad.exe to make it work

Name the file linqpad.config rather than linqpad.exe.config and LINQPad will pick it up for your queries.

 

Copyright (c) Marimer LLC