This project is read-only.

WithPath LLBLGen extension method and InterLinq

Mar 11, 2010 at 10:02 AM


Is it possible to use LLBLGen extension method with InterLinq? We are using DevExpress grid for WPF, LINQ, InterLinq, WCF, LLBLGen 2.6 and SQL server. All database keys are GUIDs.

Grid works in LINQServerMode, LINQ queries are serialized through WCF chanel with InterLinq. On the server side we use our query handler, which delegates queries to LLBLGen.


Client code:

  IQueryRemoteHandler wrapper = WcfServiceHelper.ClientChannel; // our WCF chanel

ClientQueryHandler clientQueryHandler = new ClientQueryHandler(wrapper);


Query for data:


LinqServerModeSource collectionSource = new LinqServerModeSource()
   ElementType = typeof(AuditLogDetailEntity),
   var source = (from i in clientQueryHandler.Get<AuditLogDetailEntity>()
                              join o in clientQueryHandler.Get<AuditLogEntity>() on i.AuditLogGuid equals o.AuditLogGuid
                             // we want to prefetch data from another table 
select i).WithPath(p => p.Prefetch(i => i.AuditLog)); KeyExpression = "AuditLogDetailGuid" }; grid.DataSource = collectionSource;



Creating handler:

private IQueryHandler CreateHandler()
LinqMetaData metaData = new LinqMetaData(DALProvider.GetLinqMetaData());
return new LLBLGenProQueryHandler(metaData);

// Where LLBLGenProQueryHandler is our implementation of IQueryHandler


IQueryHandler innerHandler = CreateHandler();
LINQHandler = new ServerQueryWcfHandler(innerHandler);



IQueryHandler innerHandler = CreateHandler();
LINQHandler = new ServerQueryWcfHandler(innerHandler);

 After execution we get exception:

Unable to cast object of type 'InterLinq.Communication.ClientQueryProvider' to type 'SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase'.

It is obvious that function WithPath:

public static IQueryable<TSource> WithPath<TSource>(this IQueryable<TSource> source, IPrefetchPathCore path) where TSource : IEntityCore
tries to cast IQueryable to LLBLGenProProviderBase but in fact it is ClientQueryHandler.

Any idea how to solve this problem? Should we extend ClientQueryHandler or mayby use some wrapper class? How to serialize extendet methods through InterLinq.



Feb 20, 2011 at 7:39 AM

Bruno -

Great work on the LLBLGenProQueryHandler class.  We are also using LLBLGen Pro.

Would you mind posting your code for this class?  It would be greatly appreciated!


PS.  We don't intend to serialize .WithPath() from the client.  We would like to perform all prefetching on the server and expose the resulting IQueryable.  Thus, the IQueryable can be consumed on the client - solely for the purposes of adding filters & paging.  Do you believe this is possible with InterLINQ?