[CSHARP-1444] LinqToMongo.Inject throws InvalidOperationException Created: 15/Oct/15  Updated: 05/Apr/19  Resolved: 15/Oct/15

Status: Closed
Project: C# Driver
Component/s: Linq
Affects Version/s: 2.0.1
Fix Version/s: None

Type: Task Priority: Blocker - P1
Reporter: Ilya Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: question
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Window 8 64 bit


Attachments: Text File Program.cs    
Issue Links:
Duplicate
is duplicated by CSHARP-1445 Support arbitrary filters in the LIN... Closed

 Description   

The attached code throws an InvalidOperationException() The LinqToMongo.Inject method is only intended to be used in LINQ Where clauses.

var point = new GeoJsonPoint<GeoJson2DGeographicCoordinates>(new GeoJson2DGeographicCoordinates(10, 10));
IMongoQuery query = Query<TestClass>.GeoIntersects(o => o.Coord, point);
var result = objectsCollection.AsQueryable().Where(x => query.Inject()).ToList(); // exception thrown here

In version 1.9.2 of c# driver this code was worked. I use LINQ Where. Why exception was thrown?



 Comments   
Comment by Craig Wilson [ 15/Oct/15 ]

I'm going to close this one as we will not support the old Query builder injection. However, I have opened up a feature request for this type of thing using the new builders in CSHARP-1445.

Comment by Ilya [ 15/Oct/15 ]

Sorry, version is 2.1.0-rc1. Thanks for your answer.

Comment by Craig Wilson [ 15/Oct/15 ]

Hi ilya,

You've stated that the affects version is 2.0.1. This version does not support LINQ. Can you double check the version of the driver you are actually using. We've introduced LINQ back in the 2.1 release (which is currently in rc1) but it will not support this syntax.

Craig

Comment by Ilya [ 15/Oct/15 ]

Hello. Added file with sample.

Comment by Craig Wilson [ 15/Oct/15 ]

Hi ilya,

We have a great number of tests that exercise this bit of code. Could you provide a sample console program that causes this to occur?

Thanks,
Craig

Generated at Wed Feb 07 21:39:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.