$Cond and $Eq Inside $Project - C# Driver MongoDBHow do I calculate someone's age in C#?What is the difference between String and string in C#?Hidden Features of C#?Cast int to enum in C#How do I enumerate an enum in C#?Should 'using' directives be inside or outside the namespace?What are the correct version numbers for C#?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How to query MongoDB with “like”?How do I drop a MongoDB database from the command line?

Mapping a list into a phase plot

Time travel short story where a man arrives in the late 19th century in a time machine and then sends the machine back into the past

How will losing mobility of one hand affect my career as a programmer?

Go Pregnant or Go Home

What would happen if the UK refused to take part in EU Parliamentary elections?

What are the ramifications of creating a homebrew world without an Astral Plane?

HashMap containsKey() returns false although hashCode() and equals() are true

Teaching indefinite integrals that require special-casing

The Riley Riddle Mine

Is it correct to write "is not focus on"?

The baby cries all morning

How do I define a right arrow with bar in LaTeX?

Should my PhD thesis be submitted under my legal name?

What is the term when two people sing in harmony, but they aren't singing the same notes?

How to prove that the query oracle is unitary?

Why did Kant, Hegel, and Adorno leave some words and phrases in the Greek alphabet?

Curses work by shouting - How to avoid collateral damage?

Will it be accepted, if there is no ''Main Character" stereotype?

What would be the benefits of having both a state and local currencies?

Lay out the Carpet

Is there a good way to store credentials outside of a password manager?

Why "be dealt cards" rather than "be dealing cards"?

How can I get through very long and very dry, but also very useful technical documents when learing a new tool?

Why are on-board computers allowed to change controls without notifying the pilots?



$Cond and $Eq Inside $Project - C# Driver MongoDB


How do I calculate someone's age in C#?What is the difference between String and string in C#?Hidden Features of C#?Cast int to enum in C#How do I enumerate an enum in C#?Should 'using' directives be inside or outside the namespace?What are the correct version numbers for C#?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How to query MongoDB with “like”?How do I drop a MongoDB database from the command line?













1















Im facing a litle problem in Deserializing BsonDocuments type, I couldn't find the reason, but I have some clues, maybe, it's about 0 fields, because the error tel me about the column I have 0 fields. I also realised that its a (empty array).



MY MONGO QUERY ON ROBO 3T AND THE RESULT



MY C# MONGO QUERY



 var connString = "mongodb+srv";
var client = new MongoClient(connString);
var database = client.GetDatabase("Base");
var collection = database.GetCollection<BsonDocument>("collection");

var match1 = new BsonDocument("$match", new BsonDocument("PartnerId", "2021"));
var match2 = new BsonDocument("$match", new BsonDocument("CD_CLIENTE", codCond));

var project = new BsonDocument "$project", new BsonDocument "_id", 0 , "CD_CLIENTE", 1 , "CD_ACESSO", 1 ,
"ID_ACESSO", 1 , "NOME", 1 , "NU_TELEFONE", 1 , "EMAIL", 1 , "NU_KIPER_RF", 1 , "NU_KIPER_TAG", 1 ,
"FG_KIPER_MOBILE", 1 , "KEY_HASH", 1 ,; MY MONGO AND RESULT

var sort = new BsonDocument("$sort", new BsonDocument("NOME", 1));

var pipeline = new[] match1, match2, project, sort ;
var result = collection.Aggregate<BsonDocument>(pipeline).ToList();

var lista = JsonConvert.DeserializeObject<List<UsuariosAcessos>>(result.ToJson());


The error is here:



 var lista = JsonConvert.DeserializeObject<List<UsuariosAcessos>>(result.ToJson());


Exatly when I try to Deserialise an that "empty array" to Model int?. I found a work around, because I just need to know if, we have or dont not something in NU_KIPER_TAG and NU_KIPER_RF, so, I did this new Mongo query.
NEW MONGO QUERY USING $COND



db.dbACESSO.aggregate([


$match: PartnerId: "2021", CD_CLIENTE: 4003
,


$project: _id:0, CD_CLIENTE:1, CD_ACESSO:1, ID_ACESSO:1, NOME:1, NU_TELEFONE:1,EMAIL:1, FG_KIPER_MOBILE:1,
TAG:$cond: [ $eq: [ "$NU_KIPER_TAG", ], 0, 1 ], CONTROLE:$cond: [ $eq: [ "$NU_KIPER_RF", ], 0, 1 ],
APPATIVO:$cond: [ $eq: [ "$KEY_HASH", ], "", "$KEY_HASH" ]



])


I couldnt translate it to C#, I tried hard, but i'm not familiarized with the sintaxe. I also googled for a sample with no success.



I think its something like:



var project = new BsonDocument 

"$project", new BsonDocument "_id", 0 , "CD_CLIENTE", 1 , "CD_ACESSO", 1 , "ID_ACESSO", 1 , "NOME", 1
, "NU_TELEFONE", 1 , "EMAIL", 1 , "NU_KIPER_RF", 1 , "NU_KIPER_TAG", 1 , "FG_KIPER_MOBILE", 1 , "KEY_HASH", 1 ,


"TAG", new BsonDocument"$cond", new BsonDocument "$eq", "$NU_KIPER_TAG", "", 0, 1 ],


;









share|improve this question







New contributor




Ana Paula is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    1















    Im facing a litle problem in Deserializing BsonDocuments type, I couldn't find the reason, but I have some clues, maybe, it's about 0 fields, because the error tel me about the column I have 0 fields. I also realised that its a (empty array).



    MY MONGO QUERY ON ROBO 3T AND THE RESULT



    MY C# MONGO QUERY



     var connString = "mongodb+srv";
    var client = new MongoClient(connString);
    var database = client.GetDatabase("Base");
    var collection = database.GetCollection<BsonDocument>("collection");

    var match1 = new BsonDocument("$match", new BsonDocument("PartnerId", "2021"));
    var match2 = new BsonDocument("$match", new BsonDocument("CD_CLIENTE", codCond));

    var project = new BsonDocument "$project", new BsonDocument "_id", 0 , "CD_CLIENTE", 1 , "CD_ACESSO", 1 ,
    "ID_ACESSO", 1 , "NOME", 1 , "NU_TELEFONE", 1 , "EMAIL", 1 , "NU_KIPER_RF", 1 , "NU_KIPER_TAG", 1 ,
    "FG_KIPER_MOBILE", 1 , "KEY_HASH", 1 ,; MY MONGO AND RESULT

    var sort = new BsonDocument("$sort", new BsonDocument("NOME", 1));

    var pipeline = new[] match1, match2, project, sort ;
    var result = collection.Aggregate<BsonDocument>(pipeline).ToList();

    var lista = JsonConvert.DeserializeObject<List<UsuariosAcessos>>(result.ToJson());


    The error is here:



     var lista = JsonConvert.DeserializeObject<List<UsuariosAcessos>>(result.ToJson());


    Exatly when I try to Deserialise an that "empty array" to Model int?. I found a work around, because I just need to know if, we have or dont not something in NU_KIPER_TAG and NU_KIPER_RF, so, I did this new Mongo query.
    NEW MONGO QUERY USING $COND



    db.dbACESSO.aggregate([


    $match: PartnerId: "2021", CD_CLIENTE: 4003
    ,


    $project: _id:0, CD_CLIENTE:1, CD_ACESSO:1, ID_ACESSO:1, NOME:1, NU_TELEFONE:1,EMAIL:1, FG_KIPER_MOBILE:1,
    TAG:$cond: [ $eq: [ "$NU_KIPER_TAG", ], 0, 1 ], CONTROLE:$cond: [ $eq: [ "$NU_KIPER_RF", ], 0, 1 ],
    APPATIVO:$cond: [ $eq: [ "$KEY_HASH", ], "", "$KEY_HASH" ]



    ])


    I couldnt translate it to C#, I tried hard, but i'm not familiarized with the sintaxe. I also googled for a sample with no success.



    I think its something like:



    var project = new BsonDocument 

    "$project", new BsonDocument "_id", 0 , "CD_CLIENTE", 1 , "CD_ACESSO", 1 , "ID_ACESSO", 1 , "NOME", 1
    , "NU_TELEFONE", 1 , "EMAIL", 1 , "NU_KIPER_RF", 1 , "NU_KIPER_TAG", 1 , "FG_KIPER_MOBILE", 1 , "KEY_HASH", 1 ,


    "TAG", new BsonDocument"$cond", new BsonDocument "$eq", "$NU_KIPER_TAG", "", 0, 1 ],


    ;









    share|improve this question







    New contributor




    Ana Paula is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      1












      1








      1


      1






      Im facing a litle problem in Deserializing BsonDocuments type, I couldn't find the reason, but I have some clues, maybe, it's about 0 fields, because the error tel me about the column I have 0 fields. I also realised that its a (empty array).



      MY MONGO QUERY ON ROBO 3T AND THE RESULT



      MY C# MONGO QUERY



       var connString = "mongodb+srv";
      var client = new MongoClient(connString);
      var database = client.GetDatabase("Base");
      var collection = database.GetCollection<BsonDocument>("collection");

      var match1 = new BsonDocument("$match", new BsonDocument("PartnerId", "2021"));
      var match2 = new BsonDocument("$match", new BsonDocument("CD_CLIENTE", codCond));

      var project = new BsonDocument "$project", new BsonDocument "_id", 0 , "CD_CLIENTE", 1 , "CD_ACESSO", 1 ,
      "ID_ACESSO", 1 , "NOME", 1 , "NU_TELEFONE", 1 , "EMAIL", 1 , "NU_KIPER_RF", 1 , "NU_KIPER_TAG", 1 ,
      "FG_KIPER_MOBILE", 1 , "KEY_HASH", 1 ,; MY MONGO AND RESULT

      var sort = new BsonDocument("$sort", new BsonDocument("NOME", 1));

      var pipeline = new[] match1, match2, project, sort ;
      var result = collection.Aggregate<BsonDocument>(pipeline).ToList();

      var lista = JsonConvert.DeserializeObject<List<UsuariosAcessos>>(result.ToJson());


      The error is here:



       var lista = JsonConvert.DeserializeObject<List<UsuariosAcessos>>(result.ToJson());


      Exatly when I try to Deserialise an that "empty array" to Model int?. I found a work around, because I just need to know if, we have or dont not something in NU_KIPER_TAG and NU_KIPER_RF, so, I did this new Mongo query.
      NEW MONGO QUERY USING $COND



      db.dbACESSO.aggregate([


      $match: PartnerId: "2021", CD_CLIENTE: 4003
      ,


      $project: _id:0, CD_CLIENTE:1, CD_ACESSO:1, ID_ACESSO:1, NOME:1, NU_TELEFONE:1,EMAIL:1, FG_KIPER_MOBILE:1,
      TAG:$cond: [ $eq: [ "$NU_KIPER_TAG", ], 0, 1 ], CONTROLE:$cond: [ $eq: [ "$NU_KIPER_RF", ], 0, 1 ],
      APPATIVO:$cond: [ $eq: [ "$KEY_HASH", ], "", "$KEY_HASH" ]



      ])


      I couldnt translate it to C#, I tried hard, but i'm not familiarized with the sintaxe. I also googled for a sample with no success.



      I think its something like:



      var project = new BsonDocument 

      "$project", new BsonDocument "_id", 0 , "CD_CLIENTE", 1 , "CD_ACESSO", 1 , "ID_ACESSO", 1 , "NOME", 1
      , "NU_TELEFONE", 1 , "EMAIL", 1 , "NU_KIPER_RF", 1 , "NU_KIPER_TAG", 1 , "FG_KIPER_MOBILE", 1 , "KEY_HASH", 1 ,


      "TAG", new BsonDocument"$cond", new BsonDocument "$eq", "$NU_KIPER_TAG", "", 0, 1 ],


      ;









      share|improve this question







      New contributor




      Ana Paula is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      Im facing a litle problem in Deserializing BsonDocuments type, I couldn't find the reason, but I have some clues, maybe, it's about 0 fields, because the error tel me about the column I have 0 fields. I also realised that its a (empty array).



      MY MONGO QUERY ON ROBO 3T AND THE RESULT



      MY C# MONGO QUERY



       var connString = "mongodb+srv";
      var client = new MongoClient(connString);
      var database = client.GetDatabase("Base");
      var collection = database.GetCollection<BsonDocument>("collection");

      var match1 = new BsonDocument("$match", new BsonDocument("PartnerId", "2021"));
      var match2 = new BsonDocument("$match", new BsonDocument("CD_CLIENTE", codCond));

      var project = new BsonDocument "$project", new BsonDocument "_id", 0 , "CD_CLIENTE", 1 , "CD_ACESSO", 1 ,
      "ID_ACESSO", 1 , "NOME", 1 , "NU_TELEFONE", 1 , "EMAIL", 1 , "NU_KIPER_RF", 1 , "NU_KIPER_TAG", 1 ,
      "FG_KIPER_MOBILE", 1 , "KEY_HASH", 1 ,; MY MONGO AND RESULT

      var sort = new BsonDocument("$sort", new BsonDocument("NOME", 1));

      var pipeline = new[] match1, match2, project, sort ;
      var result = collection.Aggregate<BsonDocument>(pipeline).ToList();

      var lista = JsonConvert.DeserializeObject<List<UsuariosAcessos>>(result.ToJson());


      The error is here:



       var lista = JsonConvert.DeserializeObject<List<UsuariosAcessos>>(result.ToJson());


      Exatly when I try to Deserialise an that "empty array" to Model int?. I found a work around, because I just need to know if, we have or dont not something in NU_KIPER_TAG and NU_KIPER_RF, so, I did this new Mongo query.
      NEW MONGO QUERY USING $COND



      db.dbACESSO.aggregate([


      $match: PartnerId: "2021", CD_CLIENTE: 4003
      ,


      $project: _id:0, CD_CLIENTE:1, CD_ACESSO:1, ID_ACESSO:1, NOME:1, NU_TELEFONE:1,EMAIL:1, FG_KIPER_MOBILE:1,
      TAG:$cond: [ $eq: [ "$NU_KIPER_TAG", ], 0, 1 ], CONTROLE:$cond: [ $eq: [ "$NU_KIPER_RF", ], 0, 1 ],
      APPATIVO:$cond: [ $eq: [ "$KEY_HASH", ], "", "$KEY_HASH" ]



      ])


      I couldnt translate it to C#, I tried hard, but i'm not familiarized with the sintaxe. I also googled for a sample with no success.



      I think its something like:



      var project = new BsonDocument 

      "$project", new BsonDocument "_id", 0 , "CD_CLIENTE", 1 , "CD_ACESSO", 1 , "ID_ACESSO", 1 , "NOME", 1
      , "NU_TELEFONE", 1 , "EMAIL", 1 , "NU_KIPER_RF", 1 , "NU_KIPER_TAG", 1 , "FG_KIPER_MOBILE", 1 , "KEY_HASH", 1 ,


      "TAG", new BsonDocument"$cond", new BsonDocument "$eq", "$NU_KIPER_TAG", "", 0, 1 ],


      ;






      c# mongodb






      share|improve this question







      New contributor




      Ana Paula is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Ana Paula is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Ana Paula is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Mar 21 at 15:04









      Ana PaulaAna Paula

      83




      83




      New contributor




      Ana Paula is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Ana Paula is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Ana Paula is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          2 Answers
          2






          active

          oldest

          votes


















          0














          What about using the fluent C# like this:



           var connString = "mongodb+srv";
          var client = new MongoClient(connString);
          var database = client.GetDatabase("Base");
          var collection = database.GetCollection<UsuariosAcessos>("collection"); //Here you put you Model

          var filter = Builders<UsuariosAcessos>.Filter.Eq(x => x.PartnerId, cliente)
          & Builders<UsuariosAcessos>.Filter.Eq(x => x.CD_CLIENTE, codCond);

          var lista = collection.Aggregate().Match(filter).Project(x => new UsuariosAcessos

          CD_CLIENTE = x.CD_CLIENTE,
          ID_ACESSO = x.ID_ACESSO,
          CD_ACESSO = x.CD_ACESSO,
          NOME = x.NOME,
          NU_TELEFONE = x.NU_TELEFONE,
          EMAIL = x.EMAIL,
          NU_KIPER_RF = x.NU_KIPER_RF,
          NU_KIPER_TAG = x.NU_KIPER_TAG,
          FG_KIPER_MOBILE = x.FG_KIPER_MOBILE,
          KEY_HASH = x.KEY_HASH
          ).ToList();


          About your problem at Deserialization time, I think it's not possible to translate (empty array) to int or int?, it's appear to be the reason your deserialization is not working, try to change your model.



          FROM:



          public int? NU_KIPER_TAG get; set; 
          public int? NU_KIPER_RF get; set;


          TO:



          public object NU_KIPER_TAG get; set; 
          public object NU_KIPER_RF get; set;


          Its not you are looking for, but, maybe your Deserialization are going to Work. After that, you can convert the data. Hope this helps.






          share|improve this answer


















          • 1





            I will try, ty again!

            – Ana Paula
            Mar 22 at 15:01


















          0














          I'm not sure about how to represent that empty array on the C# Driver. Try this way:



          var project = new BsonDocument 

          "$project", new BsonDocument "_id", 0 , "CD_CLIENTE", 1 , "CD_ACESSO", 1 , "ID_ACESSO", 1 , "NOME", 1
          , "NU_TELEFONE", 1 , "EMAIL", 1 , "NU_KIPER_RF", 1 , "NU_KIPER_TAG", 1 , "FG_KIPER_MOBILE", 1 , "KEY_HASH", 1 ,


          "TAG", new BsonDocument "$cond", new BsonArray new BsonDocument "$eq", new BsonArray "$NU_KIPER_TAG", "",1,0,


          ;





          share|improve this answer























          • Tks for your answer. I tried..., I got no errors, but, the results is always the same. I algo tried to replace the "" for a valid NU_KIPER_TAG Id, but the result is always the same!

            – Ana Paula
            Mar 22 at 13:44










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          Ana Paula is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55283486%2fcond-and-eq-inside-project-c-sharp-driver-mongodb%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          What about using the fluent C# like this:



           var connString = "mongodb+srv";
          var client = new MongoClient(connString);
          var database = client.GetDatabase("Base");
          var collection = database.GetCollection<UsuariosAcessos>("collection"); //Here you put you Model

          var filter = Builders<UsuariosAcessos>.Filter.Eq(x => x.PartnerId, cliente)
          & Builders<UsuariosAcessos>.Filter.Eq(x => x.CD_CLIENTE, codCond);

          var lista = collection.Aggregate().Match(filter).Project(x => new UsuariosAcessos

          CD_CLIENTE = x.CD_CLIENTE,
          ID_ACESSO = x.ID_ACESSO,
          CD_ACESSO = x.CD_ACESSO,
          NOME = x.NOME,
          NU_TELEFONE = x.NU_TELEFONE,
          EMAIL = x.EMAIL,
          NU_KIPER_RF = x.NU_KIPER_RF,
          NU_KIPER_TAG = x.NU_KIPER_TAG,
          FG_KIPER_MOBILE = x.FG_KIPER_MOBILE,
          KEY_HASH = x.KEY_HASH
          ).ToList();


          About your problem at Deserialization time, I think it's not possible to translate (empty array) to int or int?, it's appear to be the reason your deserialization is not working, try to change your model.



          FROM:



          public int? NU_KIPER_TAG get; set; 
          public int? NU_KIPER_RF get; set;


          TO:



          public object NU_KIPER_TAG get; set; 
          public object NU_KIPER_RF get; set;


          Its not you are looking for, but, maybe your Deserialization are going to Work. After that, you can convert the data. Hope this helps.






          share|improve this answer


















          • 1





            I will try, ty again!

            – Ana Paula
            Mar 22 at 15:01















          0














          What about using the fluent C# like this:



           var connString = "mongodb+srv";
          var client = new MongoClient(connString);
          var database = client.GetDatabase("Base");
          var collection = database.GetCollection<UsuariosAcessos>("collection"); //Here you put you Model

          var filter = Builders<UsuariosAcessos>.Filter.Eq(x => x.PartnerId, cliente)
          & Builders<UsuariosAcessos>.Filter.Eq(x => x.CD_CLIENTE, codCond);

          var lista = collection.Aggregate().Match(filter).Project(x => new UsuariosAcessos

          CD_CLIENTE = x.CD_CLIENTE,
          ID_ACESSO = x.ID_ACESSO,
          CD_ACESSO = x.CD_ACESSO,
          NOME = x.NOME,
          NU_TELEFONE = x.NU_TELEFONE,
          EMAIL = x.EMAIL,
          NU_KIPER_RF = x.NU_KIPER_RF,
          NU_KIPER_TAG = x.NU_KIPER_TAG,
          FG_KIPER_MOBILE = x.FG_KIPER_MOBILE,
          KEY_HASH = x.KEY_HASH
          ).ToList();


          About your problem at Deserialization time, I think it's not possible to translate (empty array) to int or int?, it's appear to be the reason your deserialization is not working, try to change your model.



          FROM:



          public int? NU_KIPER_TAG get; set; 
          public int? NU_KIPER_RF get; set;


          TO:



          public object NU_KIPER_TAG get; set; 
          public object NU_KIPER_RF get; set;


          Its not you are looking for, but, maybe your Deserialization are going to Work. After that, you can convert the data. Hope this helps.






          share|improve this answer


















          • 1





            I will try, ty again!

            – Ana Paula
            Mar 22 at 15:01













          0












          0








          0







          What about using the fluent C# like this:



           var connString = "mongodb+srv";
          var client = new MongoClient(connString);
          var database = client.GetDatabase("Base");
          var collection = database.GetCollection<UsuariosAcessos>("collection"); //Here you put you Model

          var filter = Builders<UsuariosAcessos>.Filter.Eq(x => x.PartnerId, cliente)
          & Builders<UsuariosAcessos>.Filter.Eq(x => x.CD_CLIENTE, codCond);

          var lista = collection.Aggregate().Match(filter).Project(x => new UsuariosAcessos

          CD_CLIENTE = x.CD_CLIENTE,
          ID_ACESSO = x.ID_ACESSO,
          CD_ACESSO = x.CD_ACESSO,
          NOME = x.NOME,
          NU_TELEFONE = x.NU_TELEFONE,
          EMAIL = x.EMAIL,
          NU_KIPER_RF = x.NU_KIPER_RF,
          NU_KIPER_TAG = x.NU_KIPER_TAG,
          FG_KIPER_MOBILE = x.FG_KIPER_MOBILE,
          KEY_HASH = x.KEY_HASH
          ).ToList();


          About your problem at Deserialization time, I think it's not possible to translate (empty array) to int or int?, it's appear to be the reason your deserialization is not working, try to change your model.



          FROM:



          public int? NU_KIPER_TAG get; set; 
          public int? NU_KIPER_RF get; set;


          TO:



          public object NU_KIPER_TAG get; set; 
          public object NU_KIPER_RF get; set;


          Its not you are looking for, but, maybe your Deserialization are going to Work. After that, you can convert the data. Hope this helps.






          share|improve this answer













          What about using the fluent C# like this:



           var connString = "mongodb+srv";
          var client = new MongoClient(connString);
          var database = client.GetDatabase("Base");
          var collection = database.GetCollection<UsuariosAcessos>("collection"); //Here you put you Model

          var filter = Builders<UsuariosAcessos>.Filter.Eq(x => x.PartnerId, cliente)
          & Builders<UsuariosAcessos>.Filter.Eq(x => x.CD_CLIENTE, codCond);

          var lista = collection.Aggregate().Match(filter).Project(x => new UsuariosAcessos

          CD_CLIENTE = x.CD_CLIENTE,
          ID_ACESSO = x.ID_ACESSO,
          CD_ACESSO = x.CD_ACESSO,
          NOME = x.NOME,
          NU_TELEFONE = x.NU_TELEFONE,
          EMAIL = x.EMAIL,
          NU_KIPER_RF = x.NU_KIPER_RF,
          NU_KIPER_TAG = x.NU_KIPER_TAG,
          FG_KIPER_MOBILE = x.FG_KIPER_MOBILE,
          KEY_HASH = x.KEY_HASH
          ).ToList();


          About your problem at Deserialization time, I think it's not possible to translate (empty array) to int or int?, it's appear to be the reason your deserialization is not working, try to change your model.



          FROM:



          public int? NU_KIPER_TAG get; set; 
          public int? NU_KIPER_RF get; set;


          TO:



          public object NU_KIPER_TAG get; set; 
          public object NU_KIPER_RF get; set;


          Its not you are looking for, but, maybe your Deserialization are going to Work. After that, you can convert the data. Hope this helps.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 22 at 14:59









          Rogerio AzevedoRogerio Azevedo

          270219




          270219







          • 1





            I will try, ty again!

            – Ana Paula
            Mar 22 at 15:01












          • 1





            I will try, ty again!

            – Ana Paula
            Mar 22 at 15:01







          1




          1





          I will try, ty again!

          – Ana Paula
          Mar 22 at 15:01





          I will try, ty again!

          – Ana Paula
          Mar 22 at 15:01













          0














          I'm not sure about how to represent that empty array on the C# Driver. Try this way:



          var project = new BsonDocument 

          "$project", new BsonDocument "_id", 0 , "CD_CLIENTE", 1 , "CD_ACESSO", 1 , "ID_ACESSO", 1 , "NOME", 1
          , "NU_TELEFONE", 1 , "EMAIL", 1 , "NU_KIPER_RF", 1 , "NU_KIPER_TAG", 1 , "FG_KIPER_MOBILE", 1 , "KEY_HASH", 1 ,


          "TAG", new BsonDocument "$cond", new BsonArray new BsonDocument "$eq", new BsonArray "$NU_KIPER_TAG", "",1,0,


          ;





          share|improve this answer























          • Tks for your answer. I tried..., I got no errors, but, the results is always the same. I algo tried to replace the "" for a valid NU_KIPER_TAG Id, but the result is always the same!

            – Ana Paula
            Mar 22 at 13:44















          0














          I'm not sure about how to represent that empty array on the C# Driver. Try this way:



          var project = new BsonDocument 

          "$project", new BsonDocument "_id", 0 , "CD_CLIENTE", 1 , "CD_ACESSO", 1 , "ID_ACESSO", 1 , "NOME", 1
          , "NU_TELEFONE", 1 , "EMAIL", 1 , "NU_KIPER_RF", 1 , "NU_KIPER_TAG", 1 , "FG_KIPER_MOBILE", 1 , "KEY_HASH", 1 ,


          "TAG", new BsonDocument "$cond", new BsonArray new BsonDocument "$eq", new BsonArray "$NU_KIPER_TAG", "",1,0,


          ;





          share|improve this answer























          • Tks for your answer. I tried..., I got no errors, but, the results is always the same. I algo tried to replace the "" for a valid NU_KIPER_TAG Id, but the result is always the same!

            – Ana Paula
            Mar 22 at 13:44













          0












          0








          0







          I'm not sure about how to represent that empty array on the C# Driver. Try this way:



          var project = new BsonDocument 

          "$project", new BsonDocument "_id", 0 , "CD_CLIENTE", 1 , "CD_ACESSO", 1 , "ID_ACESSO", 1 , "NOME", 1
          , "NU_TELEFONE", 1 , "EMAIL", 1 , "NU_KIPER_RF", 1 , "NU_KIPER_TAG", 1 , "FG_KIPER_MOBILE", 1 , "KEY_HASH", 1 ,


          "TAG", new BsonDocument "$cond", new BsonArray new BsonDocument "$eq", new BsonArray "$NU_KIPER_TAG", "",1,0,


          ;





          share|improve this answer













          I'm not sure about how to represent that empty array on the C# Driver. Try this way:



          var project = new BsonDocument 

          "$project", new BsonDocument "_id", 0 , "CD_CLIENTE", 1 , "CD_ACESSO", 1 , "ID_ACESSO", 1 , "NOME", 1
          , "NU_TELEFONE", 1 , "EMAIL", 1 , "NU_KIPER_RF", 1 , "NU_KIPER_TAG", 1 , "FG_KIPER_MOBILE", 1 , "KEY_HASH", 1 ,


          "TAG", new BsonDocument "$cond", new BsonArray new BsonDocument "$eq", new BsonArray "$NU_KIPER_TAG", "",1,0,


          ;






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 22 at 13:15









          Rogerio AzevedoRogerio Azevedo

          270219




          270219












          • Tks for your answer. I tried..., I got no errors, but, the results is always the same. I algo tried to replace the "" for a valid NU_KIPER_TAG Id, but the result is always the same!

            – Ana Paula
            Mar 22 at 13:44

















          • Tks for your answer. I tried..., I got no errors, but, the results is always the same. I algo tried to replace the "" for a valid NU_KIPER_TAG Id, but the result is always the same!

            – Ana Paula
            Mar 22 at 13:44
















          Tks for your answer. I tried..., I got no errors, but, the results is always the same. I algo tried to replace the "" for a valid NU_KIPER_TAG Id, but the result is always the same!

          – Ana Paula
          Mar 22 at 13:44





          Tks for your answer. I tried..., I got no errors, but, the results is always the same. I algo tried to replace the "" for a valid NU_KIPER_TAG Id, but the result is always the same!

          – Ana Paula
          Mar 22 at 13:44










          Ana Paula is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          Ana Paula is a new contributor. Be nice, and check out our Code of Conduct.












          Ana Paula is a new contributor. Be nice, and check out our Code of Conduct.











          Ana Paula is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55283486%2fcond-and-eq-inside-project-c-sharp-driver-mongodb%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해