Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi Guys,

Actually, I tried to perform joins on MongoDB using C# driver.
as, that's not possible. I've tried to create a function on mongoDB and get the query result to my C# code. But I'm unable to get the result.

My MongoDB Function

JavaScript
function(GroupId) {
  var contacts = db.CLIENT_CONTACTS.find({
    Group_Id: GroupId
  }, {
    MOBILE_NUMBER: 1,
    _id: 0
  });
  var dd = '';
  var abc = contacts.forEach(
    function(x) {
      dd = dd + ',' + x.MOBILE_NUMBER;
    })
  dd = dd.substring(1, dd.length)
  var number = dd.split(',')
  return db.USERINFO.find({
    'MOBILENO': {
      $in: number
    }
  }, {
    GENDER: 1,
    MOBILENO: 1,
    _id: 0
  })
}

So, My function result will be a Collection with 2 columns.
Actually, I've tried some piece of code for getting the mongoDB function result.

My C# Code

C#
BsonValue bv = MongoConnection.database.Eval("GetUnMeContacts");
BsonValue bv1 = MongoConnection.database.Eval(bv.AsBsonJavaScript.Code, 3262);
Console.WriteLine(bv1);


But, I'm not getting the result. I've taken a screenshot of my result.
Actually, I'm getting the mongoDB function query and some other properties in the result.

Can anyone suggest me the correct way to get the result?
Thanks in advance.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900