ASP .Net OData -> Linq -> N1QL

Has anyone successfully built an OData endpoint on top of N1QL in ASP .Net?
So far it looks like the way the OData middleware parses the $filter clause hits unimplemented methods in the Linq to N1QL library.

Here is the simple url with a filter clause: http://localhost:32143/Odata/Visits?$filter=DrgCode eq ‘919’

{“error”:{“code”:"",“message”:“An error has occurred.”,“innererror”:{“message”:“Exception has been thrown by the target of an invocation.”,“type”:“System.Reflection.TargetInvocationException”,“stacktrace”:" at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)

“internalexception”:{“message”:“The expression ‘[$it].Extended.ContainsKey(“drgCode”)’ (type: System.Linq.Expressions.MethodCallExpression) is not supported by this LINQ provider.”,“type”:“System.NotSupportedException”,“stacktrace”:" at Remotion.Linq.Parsing

After a few sips of very strong coffee I realized that in the lower half of monster stack trace the $it.Extended was actually referring to a property on my model of type Dictionary<string, dynamic>.
So in my WebApiConfig.cs where I am manually constructing the EDM model I added the following line:

var ve = builder.EntityType().HasKey(v => v.DocId);
ve.Ignore(v => v.Extended);

works like a charm now.

1 Like