InterLINQ and GUID as a primary key

Mar 9, 2010 at 11:51 PM

Does InterLINQ supports GUIDS as a primary keys? After trying to sort column i got exception with message like "Exception has been thrown by the target of an invocation" and there is "no reason". On the server side I get "The binary expression '([508].CompareTo(6FBAF6F1-3786-415d-B832-7FA9A6CF4FB8) < 0' can't be converted to a predicate expression." I assume that something is wrong with GUID. Am I right?


Any idea for solution?



Mar 10, 2010 at 11:02 PM

Hi Bruno

Can you tell a bit more about your environment? Which QueryHandler did you use and how does the Linq-Query look like?

I made a small example-Project to test if InterLinq can handle GuIds. Unfortunately I don't see a way how I can upload it here, so I describe it here shortly.

I made a class Car


    public class Car
        public Guid Id { get; set; }
        public string Model { get; set; }
        public string Brand { get; set; }


then I created an ObjectQueryHandler on the server and queried it on the client via WCF with the following statement:


var cars = from c in clientQueryHandler.Get<Car>()
                                         where c.Id.CompareTo(Guid.Empty)>0
                                         orderby c.Id
                                         select c;


this worked fine. I received all Cars with Id > 0 correctly ordered. So so far it worked, but I didn't try any more complex queries.

Kind regards


Mar 11, 2010 at 8:38 AM
Edited Mar 11, 2010 at 8:41 AM


we are using DevExpress grid for WPF, LINQ, InterLinq, WCF, LLBLGen 2.6 and SQL server. All database keys are GUIDs.

We are able to get all data from any table but there is a problem with filtering.

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. But when I filter colum exception is thrown

Client code:

IQueryRemoteHandler wrapper = WcfServiceHelper.ClientChannel; // our WCF chanel
ClientQueryHandler clientQueryHandler = new ClientQueryHandler(wrapper);


Query for data:

var source = (from i in clientQueryHandler.Get<AuditLogDetailEntity>()                            
                              select i);


LinqServerModeSource collectionSource = new LinqServerModeSource()
   ElementType = typeof(AuditLogDetailEntity),
   QueryableSource = from i in clientQueryHandler.Get<AuditLogDetailEntity>()
                              select i,
    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);

When I want to sort colum method Retrieve(InterLinq.Expressions.SerializableExpression expression) in service gets expression. First one is Ok and the second one looks like the followinch string:

{Count(Where(ThenBy(OrderBy(Select(InterLinqQuery`1<AuditLogDetailEntity>, i => i),  => .FieldName),  => .AuditLogDetailGuid),  => ((Compare(.FieldName, "LocalisedBinary") < 0) || ((.FieldName = "LocalisedBinary") && (.AuditLogDetailGuid.CompareTo(57f73b00-26b1-11df-8600-001c2311de1b) < 0)))))}

After execution we get exception:

"The binary expression '([508].CompareTo(6FBAF6F1-3786-415d-B832-7FA9A6CF4FB8) < 0' can't be converted to a predicate expression."

Any idea?



Mar 16, 2010 at 8:14 PM

Hi Bruno

Sorry for the long delay. Could you send us your solution, or the part where it crashes? That would help us to reconstruct the error faster. Right now I can't tell if the exception comes from the QueryHandler, the Linq To LLBLGen Pro- Component or from InterLinq.

Kind regards


Mar 18, 2010 at 11:30 AM

LLBLGen team has already helped us. It was missing function mapping for guids. Here is the solution.