This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | using System; | |
| namespace RedisPublisher | |
| { | |
| class Program | |
| { | |
| private static RedisPubSub _pubSub; | |
| private static string _channelName; | |
| static void Main(string[] args) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | using System; | |
| using StackExchange.Redis; | |
| using static StackExchange.Redis.RedisChannel; | |
| namespace RedisPublisher | |
| { | |
| public class RedisPubSub | |
| { | |
| private readonly ConnectionMultiplexer _redis; | |
| private readonly ISubscriber _subscriber; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | using System; | |
| namespace RedisPublisher | |
| { | |
| class Program | |
| { | |
| private static RedisPubSub _pubSub; | |
| private static string _channelName; | |
| static void Main(string[] args) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public void Subscribe(string channelName, Action<string, string> callback) | |
| { | |
| _subscriber.Subscribe(channelName,(channel, value)=>{ | |
| callback(channel.ToString(), value.ToString()); | |
| }); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | using System; | |
| namespace RedisPublisher | |
| { | |
| class Program | |
| { | |
| private static RedisPubSub _pubSub; | |
| private static string _channelName; | |
| static void Main(string[] args) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | using System; | |
| using StackExchange.Redis; | |
| namespace RedisPublisher | |
| { | |
| public class RedisPubSub | |
| { | |
| private readonly ConnectionMultiplexer _redis; | |
| private readonly ISubscriber _subscriber; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class Pessoa | |
| { | |
| public string Nome {get; private set;} | |
| public string Cpf {get; private set;} | |
| public Pessoa(string nome, string cpf) | |
| { | |
| Nome = nome; | |
| Cpf = cpf; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | { | |
| $lookup: | |
| { | |
| from: "Nome da coleção", | |
| localField: "Nome do campo da coleção atual", | |
| foreignField: "Campo de identificação na coleção do lookup", | |
| as: "Nome do campo de saída" | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | db.Students.aggregate([{ | |
| $lookup: { | |
| from: "Scores", | |
| localField: "_id", | |
| foreignField: "student", | |
| as: "scores" | |
| } | |
| },{ | |
| $project: { | |
| _id: false, | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var scores = db.Scores.aggregate([ | |
| { $group : { _id: "$student", finalScore: { $avg: "$score" } } }, | |
| { $project: { average: { $avg: "$finalScore" } } } | |
| ]); | |
| scores.forEach(function(score){ | |
| print({ student: db.Students.findOne({_id: score._id}).name, grade: score.average }); | |
| }); | 
NewerOlder