[CSHARP-42] StartsWith, Contains Linq expression bug Created: 16/Jun/10  Updated: 19/Oct/16  Resolved: 19/Jun/10

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

Type: Bug Priority: Major - P3
Reporter: nisbus Assignee: Craig Wilson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows, VS2010


Attachments: Zip Archive MongoExperiment.zip    

 Description   

When creating a query like so:

public class MongoContext
{
public IQueryable<SomeObject> Objects
{
get

{ return collection.Linq(); }

}
}

and calling it with the following:

var objectsThatStartWithA = mongoContext.Objects.Where(o => o.Name.StartsWith("A"));

Or:

var objectsThatStartWithA = mongoContext.Objects.Where(o => o.Name.Contains("A"));

You get the correct instances from Mongo but all properties are set to null.

I would guess the best way to implement these would be to use regular expressions although I wasn't able to get these working correctly:

db.ObjectsDb.Find(

{ Name: /"A"*/ }

)
And
db.ObjectsDb.Find(

{ Name: /*"A"*/ }

)



 Comments   
Comment by Craig Wilson [ 19/Jun/10 ]

I have fixed the problem. It related to how and when we added the discriminator to a document. When going through linq, an empty field selection list was passed to the serializer. Because it was a derived type, we added the discriminator to the list, which resulted in only the discriminator getting selected. This has been corrected in the Linq provider. Nothing else should have this problem.

Comment by nisbus [ 19/Jun/10 ]

Here is a sample console app that demonstrates the error.

Comment by nisbus [ 19/Jun/10 ]

That's correct.

Comment by Craig Wilson [ 19/Jun/10 ]

These are implemented using regular expressions already. What gets me wondering is about all the null properties.

What I understand you saying is that when you use one of these functions, none of the properties of the returned object have any data in them. Is this correct?

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