I have a mongo collection with a composite Id containing docs that looks something like this:
{
"_id" : {
"Id1" : NumberLong(123),
"Id2" : NumberInt(45),
"Guid1" : "Guid1"
"Guid2" : "Guid2"
},
"Field1" : NumberInt(1),
"Field2" : 0.0,
"Field3" : "String value",
}
I want to select multiple documents (thousands) from this collection by providing a list of only _Id.Id1 and _Id.Id2 pairs. I'm not sure how to do this in MongoDB or in the .Net driver, let alone if its even possible.
If my question isn't clear, I'll pseudo it as best I can:
class QueryCriteria
{
Int64 Id1,
Int Id2,
}
Public GetList(List<QueryCriteria> criteria)
{
List<ResultModel> results = _collection.Find<ResultModel>(
(x, criteria) =>
x._id.Id1 == criteria.Id1 &&
x._id.Id2 == criteria.Id2 )
}
SQL Pseudo (If SQL also had the ability to have a column be an entire object)
SELECT Table1.*
FROM Table1 T1
JOIN Table2 T2
ON T1._id.Id1 = T2.Id1
AND T1._id.Id2 = T2.Id2
Some context: Selecting all documents from mongo and filtering in memory using linq is taking to long, I'm chasing performance here by trying to hive off some of the processing to Mongo.