MongoDB函数结果为c# [英] MongoDB Function result to c#

查看:65
本文介绍了MongoDB函数结果为c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨大家好,



实际上,我尝试使用C#驱动程序在MongoDB上执行连接。

as,这是不可能的。我试图在mongoDB上创建一个函数,并将查询结果提供给我的C#代码。但是我无法得到结果。



我的MongoDB功能



  function (GroupId){
var contacts = db.CLIENT_CONTACTS.find({
Group_Id:GroupId
},{
MOBILE_NUMBER: 1
_id:< span class =code-digit> 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
})
}



所以,我的函数结果将是一个包含2列的集合。

实际上,我已经尝试了一些代码来获取mongoDB函数的结果。 />


我的C#代码



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





但是,我没有得到结果。我已经对我的结果进行了截图

实际上,我正在获取mongoDB功能查询和结果中的其他一些属性。



有人能建议我得到结果的正确方法吗?

提前致谢

解决方案

in:number
}
},{
GENDER: 1
MOBILENO: 1
_id: 0
})
}



所以,我的函数结果将是一个包含2列的集合。

实际上,我试过了获取mongoDB函数结果的一段代码。



我的C#代码



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





但是,我没有得到结果。我已经对我的结果进行了截图

实际上,我正在获取mongoDB功能查询和结果中的其他一些属性。



有人能建议我得到结果的正确方法吗?

提前致谢


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

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

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.

解决方案

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

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.


这篇关于MongoDB函数结果为c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆