Re: Linq query via OData WCF Data Service problems

282 views
Skip to first unread message

craiggwilson

unread,
Oct 2, 2012, 5:00:52 PM10/2/12
to mongod...@googlegroups.com
If you are going to use the reflection provider, you will need to employ a couple of tricks to make it work.  This is an issue with how WCF Data Services interacts with an object model.  You can read about this here: http://blog.davidebbo.com/2011/08/how-odata-quirk-killed-nuget-server.html.

Alternatively, I have written a project that handles this for you already here: https://github.com/craiggwilson/mongo-dotnet-odata.  I'm still working on Update support.  It is mostly finished, I just haven't finished getting it fully tested, so you can pull the source.  If you don't need updating, just go to nuget and pull down MongoDB.OData.

On Tuesday, October 2, 2012 3:04:28 PM UTC-5, Greg Vazzana wrote:
Hi,

I am trying to hook up a Mongo back-end to expose OData via WCF Data Services.  For some reason when I run a query through the service such as:

http://localhost/odata/MyData()?$filter=substringof('New',Name)

An exception is thrown.  I have tracked it down to
protected virtual Expression VisitConditional(ConditionalExpression node) in ExpressionVisitor.cs where data types do not match because one size of the conditional is Boolean and the other is Nullable<Boolean>.

According to the debugger this is the expression getting processed:
.If ($it.Name == null) {
    null
} .Else {
    (System.Nullable`1[System.Boolean]).Call ($it.Name).Contains("New")
}

Anyone have any thoughts?

Thanks,

bot head

unread,
Apr 29, 2014, 3:25:05 PM4/29/14
to mongod...@googlegroups.com
This was a very helpful post.  If you are working with Web API 2 you can use the HandleNullPropagationOption enumeration provided by the framework in the EnableQueryAttribute class.  This will also get you past the null propagation issue.
Reply all
Reply to author
Forward
0 new messages