All Questions
Tagged with mongodb-query c#
455
questions
0
votes
0
answers
41
views
MongoDB driver Linq Last operation not supported
I am using MongoDB driver 2.19.0. In Mongo collection, document has 1 list of statuses and I want to sort all documents based on the last element of statuses list.
So sort query is
orderbyquery = s =&...
0
votes
0
answers
27
views
Unable to determine the serialization information for DateTime
I am trying to run mongoDB query in c#. I need to get records in descending order of UpdatedDate. UpdatedDate is stored in string format e.g. 9/9/2022 9:55:16 PM
var collection1 = _collection
....
0
votes
0
answers
51
views
MongoDB C# Sort based on conditional column
I have an entity with 2 dates, something like this simplified entity:
public sealed class Foo
{
public DateTime DateA { get; set; }
public DateTime DateB { get; set; }
}
I need to sort ...
1
vote
1
answer
131
views
Logging MongoDb queries for debugging
Log the MongoDb queries that are executed based on the business logic into console or log file.
ASP.NET Core, Mongo client, Mongo DB, LINQ.
I want this to understand how my queries are translated and ...
0
votes
0
answers
72
views
MongoDB.Driver multiple Unwind and Group
I am trying to filter multiple field for retrieving not deleted Document and its not deleted collection items.
Here is my example code.
var filter = Builders<Document>.Filter.Eq(rp => rp....
1
vote
1
answer
180
views
How to convert a MongoDB query with "UnionWith" to C# MongoDB.Driver
I'm using .NET 8 And MongoDB.Driver 2.24 and I have the following model in C#:
public class MachineOperation
{
public int TotalProduction { get; set; }
public int TotalBad { get; set; }
...
0
votes
1
answer
34
views
Filter with custom condition in mongo DB query not working
I have a collection with date time field. I want to filter the data with id and datetime field. Need to check the difference in milliseconds. But getting following error
Unhandled exception. System....
0
votes
1
answer
144
views
With the mongoDB C# driver, how do I execute a runCommand with args?
I have a (for me) very complex mongo query, something like this:
public void GetData(ObjectId projectId, IList<ObjectId> users)
{
var query = @"
db.getCollection("users")....
0
votes
0
answers
18
views
IMongoQueryable GroupBy and Select SUM results in 0
Trying to get a grouped list with IMongoQueryable, the sum of the processingTimes (decimal) is always 0.
IMongoQueryable<RouteMonitor> query = (IMongoQueryable<RouteMonitor>)GetQueryable(...
0
votes
0
answers
119
views
How to quickly cursor over a DocumentDB collection with the C# MongoDB Driver
I have a C# console application (.NET Framework 4.7.2) that's been running just fine for years. It iterates over a MongoDB collection. The MongoDB collection was recently moved into DocumentDB in ...
0
votes
0
answers
43
views
MongoDB $lookup is persisting combined document in database
I've 2 separate collections and I am trying to fetch joined result from MongoDB using C# driver.
public class ModuleEntity
{
public Guid Id { get; private set; }
public int UserId { get; ...
0
votes
1
answer
89
views
How to create a filter that matches a nested value against a value of the parent collection in mongodb?
Consider the following collection:
{
"_id" : (guid),
"basePrice" : 5000,
"productCategories" : [{
"_id" : (Guid),
"categoryName"...
0
votes
0
answers
123
views
Issue with Projection in MongoDB C# Driver Using $facet Stage
Background:
I'm working with the MongoDB C# driver and facing a projection issue when using the $facet stage in an aggregation pipeline. The projection works as expected in a simple scenario but fails ...
0
votes
0
answers
54
views
Mongodb c# a query with multiple Conditions from many collections
As a newbie to Mongodb am facing this problem to query from different collection based on conditions from those collections and not just one:
I'm actually recieve a user email as a query request to my ...
0
votes
1
answer
126
views
MongoDb query on byte[] with the C# driver throwing ExpressionNotSupportedException
I'm new to MongoDB and I have the following query
var personList = collection.Find
(p => p.EmailAddressSha512 == PiSha512.CreateSha512(emailAddress.ToLower())).ToList();
Executing the query ...