How to use QuerySpec, Async/Await and dynamic connection strings

Posts   
 
    
khorvat avatar
khorvat
User
Posts: 65
Joined: 17-Feb-2011
# Posted on: 29-Jun-2015 10:21:26   

Hi,

we have existing project that is using multiple databases (same catalog) and we need to dynamically set connection string. In few projects we successfully use EF & LLBLGen Adapter to do so but now we need to create a new project that needs to async/await all the way.

From what I have been reading our only option is QuerySpec as it has full async/await support ? If that is the case, can you please point us to docs explaining how to change the connection string dynamically ?

Thanks

LLBLGen 4.2 PostgreSQL 9.4

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 29-Jun-2015 20:48:26   

QuerySpec works on top of the SelfServicing or DataAccessAdapter, so in your case you should use the DataAccessAdapter CTor to set the Connection string, please check this: Adapter

Linq also has async/await support. With queryspec it's easier to control the adapter and thus the connection string, but in linq it's possible too:

Code: // Adapter // define the query var q = from c in metaData.Customers select c;

// .. later set the adapter instance using(var adapter = new DataAccessAdapter(/pass the ConnString here/)) { ((LLBLGenProProvider2)((IQueryable)q).Provider).Adapter = adapter; }

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 29-Jun-2015 21:30:53   

Also why did you think async/await is only available in queryspec? -> http://www.llblgen.com/documentation/4.2/LLBLGen%20Pro%20RTF/hh_goto.htm#Using%20the%20generated%20code/Async/gencode_async_gettingstarted.htm Manual clearly defined 3 sections about async, one for queryspec, one for linq and one for the low level api.

Frans Bouma | Lead developer LLBLGen Pro
khorvat avatar
khorvat
User
Posts: 65
Joined: 17-Feb-2011
# Posted on: 30-Jun-2015 10:04:33   

Hi all,

I have found the following :

...the Async API is also available in the Low-level query API, though not all methods of the low-level API have an async variant.

...There are also no async variants for methods which fetch a single entity, because one should use Linq or QuerySpec to do so, which do offer asynchronous single-entity fetch constructs...

I have used low-level API for almost all async methods but I'm still missing ones you mentioned. As I need to fetch single entity asynchronously I need a way to override the connection string dynamically so @Walaa Thanks, I'll try to override the query with my existing adapter and get back to you.

BTW GMail is still sending your forum e-mails to SPAM, is there anything I can do on my side to prevent this ?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 01-Jul-2015 07:39:39   

khorvat wrote:

Hi all,

I have found the following :

...the Async API is also available in the Low-level query API, though not all methods of the low-level API have an async variant.

Quoting the same documentation section:

Docs wrote:

This is because the fetch uses the FetchEntity method on adapter and a call to a generated method in SelfServicing, requiring more code to be ported / copied to make things async than reasonable, so we left that synchronously. Fetches of entities are single row returning queries using PK filters, so the queries should execute very quickly and the delay be minimal, so making this piece of the pipeline asynchronous wouldn't make things behave that differently, hence we left it as-is.

...There are also no async variants for methods which fetch a single entity, because one should use Linq or QuerySpec to do so, which do offer asynchronous single-entity fetch constructs...

khorvat wrote:

BTW GMail is still sending your forum e-mails to SPAM, is there anything I can do on my side to prevent this ?

Have you tried to mark the mail as "Not Spam"?

David Elizondo | LLBLGen Support Team
khorvat avatar
khorvat
User
Posts: 65
Joined: 17-Feb-2011
# Posted on: 01-Jul-2015 15:55:50   

Hi Daelmo,

I know and understand why you left the methods synchronous but I need them to be async so I'll try QuerySpec if there are no other options.

Have you tried to mark the mail as "Not Spam"?

Of course I marked them Not Spam, every single time - no luck yet.

Thanks