[CSHARP-718] Support Is Nothing in a VB.NET Linq Expression Created: 02/Apr/13  Updated: 20/Mar/14  Resolved: 11/Apr/13

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

Type: Bug Priority: Major - P3
Reporter: Giuseppe Assignee: Sridhar Nanjundeswaran
Resolution: Done Votes: 0
Labels: is, isnothing, linq,query, net, vb
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

visual studio 2010 , mongo c# driver 1.8 vb net



 Description   

This istruction is not supported in VB
Dim postQuerable As IQueryable(Of Post) = New MongoDB.Driver.Linq.MongoQueryable(Of Post)(New MongoQueryProvider(posts))
Dim postsWithComments = From p In postQuerable
Where p.Lista Is Nothing And p.Lista.Count > 0
Select p

but this is
var postsWithComments = from p in posts.AsQueryable()
where p.Comments != null && p.Comments.Count > 0
select p;

Do you think to implement a full support for VB ?



 Comments   
Comment by auto [ 11/Apr/13 ]

Author:

{u'date': u'2013-04-10T20:30:03Z', u'name': u'Sridhar Nanjundeswaran', u'email': u'sridhar@10gen.com'}

Message: CSHARP-718 - Normalize VB Nothing comparison
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/050fe3fe1db08af713ffdb6a3e06b1996050b031

Comment by Giuseppe [ 03/Apr/13 ]

even modifying the code in
Where p.Lista Isnot Nothing And p.Lista.Count > 0

Unsupported where clause: ((Object)p.Lista != null).
at MongoDB.Driver.Linq.PredicateTranslator.BuildQuery(Expression expression) at MongoDB.Driver.Linq.PredicateTranslator.BuildAndAlsoQuery(BinaryExpression binaryExpression) at MongoDB.Driver.Linq.PredicateTranslator.BuildAndQuery(BinaryExpression binaryExpression) at MongoDB.Driver.Linq.PredicateTranslator.BuildQuery(Expression expression) at MongoDB.Driver.Linq.SelectQuery.BuildQuery() at MongoDB.Driver.Linq.SelectQuery.Execute() at MongoDB.Driver.Linq.MongoQueryProvider.Execute(Expression expression) at MongoDB.Driver.Linq.MongoQueryProvider.Execute[TResult](Expression expression) at System.Linq.Queryable.ElementAtOrDefault[TSource](IQueryable`1 source, Int32 index) at DEMO.Form1.leggiconwhere() in E:\Disco I\DEV\NET\MONGODB\DEMO\DEMO\Form1.vb:line 125

Comment by Giuseppe [ 03/Apr/13 ]

"Unsupported where clause: ((Object)p.Lista == null)."
at MongoDB.Driver.Linq.PredicateTranslator.BuildQuery(Expression expression) at MongoDB.Driver.Linq.PredicateTranslator.BuildAndAlsoQuery(BinaryExpression binaryExpression) at MongoDB.Driver.Linq.PredicateTranslator.BuildAndQuery(BinaryExpression binaryExpression) at MongoDB.Driver.Linq.PredicateTranslator.BuildQuery(Expression expression) at MongoDB.Driver.Linq.SelectQuery.BuildQuery() at MongoDB.Driver.Linq.SelectQuery.Execute() at MongoDB.Driver.Linq.MongoQueryProvider.Execute(Expression expression) at MongoDB.Driver.Linq.MongoQueryProvider.Execute[TResult](Expression expression) at System.Linq.Queryable.ElementAtOrDefault[TSource](IQueryable`1 source, Int32 index) at DEMO.Form1.leggiconwhere() in E:\Disco I\DEV\NET\MONGODB\DEMO\DEMO\Form1.vb:line 125

Comment by Craig Wilson [ 02/Apr/13 ]

This is likely just a scenario we don't have a test for. I assume the problem is in the Is Nothing comparison. Can you add a stacktrace of the exception?

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