[CSHARP-1664] Allow dynamically created Expression<Func<>> to be used in a Mongo Linq query Created: 12/May/16  Updated: 23/Sep/16  Resolved: 09/Aug/16

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

Type: New Feature Priority: Trivial - P5
Reporter: Alexandar Aramov Assignee: Craig Wilson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

var filter = FilterBuilder.BuildExpressionFilter<BetPurchase>()

var query = _storage.AsQueryable()
.Where(p => p.Selections.AsQueryable().Where(filter).Any());

This won't work because AsQueryable is not supported.



 Comments   
Comment by Githook User [ 09/Aug/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1664: cleaning up and adding contributor.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/444e1aa1c92c7eafbfc467f846974bccdd520da8

Comment by Githook User [ 09/Aug/16 ]

Author:

{u'username': u'alex687', u'name': u'Alexandar Aramov', u'email': u'alex.aramov@gmail.com'}

Message: CSHARP-1664 fixing namespace
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/7017a89762580e4d67245791c67cc11bd5218058

Comment by Githook User [ 09/Aug/16 ]

Author:

{u'username': u'alex687', u'name': u'Alexandar Aramov', u'email': u'alex.aramov@gmail.com'}

Message: CSHARP-1664 Adding AsQuerableBinder to infoBinders, getting the dynamically created expression , some unit tests
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/f7cf7fbe1345776c275ca3efa261d748cc877ff4

Comment by Githook User [ 09/Aug/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1664: cleaning up and adding contributor.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/444e1aa1c92c7eafbfc467f846974bccdd520da8

Comment by Githook User [ 09/Aug/16 ]

Author:

{u'username': u'alex687', u'name': u'Alexandar Aramov', u'email': u'alex.aramov@gmail.com'}

Message: CSHARP-1664 fixing namespace
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/7017a89762580e4d67245791c67cc11bd5218058

Comment by Githook User [ 09/Aug/16 ]

Author:

{u'username': u'alex687', u'name': u'Alexandar Aramov', u'email': u'alex.aramov@gmail.com'}

Message: CSHARP-1664 Adding AsQuerableBinder to infoBinders, getting the dynamically created expression , some unit tests
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/f7cf7fbe1345776c275ca3efa261d748cc877ff4

Comment by Craig Wilson [ 16/May/16 ]

PR: https://github.com/mongodb/mongo-csharp-driver/pull/237

Comment by Craig Wilson [ 16/May/16 ]

Ok, I'll schedule it in for 2.3.

Thanks for the PR.

Comment by Alexandar Aramov [ 12/May/16 ]

Hi Craig ,

Basically yes , I can't pass Expression<Func<T,bool> without AsQueryable().

Alex

Comment by Craig Wilson [ 12/May/16 ]

Hi Alexandar,

Thanks for your pull request. It looks great.

My only question is why users would be doing this. This is effectively a no-op (as is obvious from your pull request). Is the scenario here that you can't pass an Expression<Func<T,bool>> in an embedded context without using AsQueryable()?

Craig

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