当前位置: 首页>>代码示例>>C#>>正文


C# IStore.GetCollection方法代码示例

本文整理汇总了C#中IStore.GetCollection方法的典型用法代码示例。如果您正苦于以下问题:C# IStore.GetCollection方法的具体用法?C# IStore.GetCollection怎么用?C# IStore.GetCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IStore的用法示例。


在下文中一共展示了IStore.GetCollection方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Set

        // A method that handles densodb events MUST have this delegate.
        public static void Set(IStore dbstore, BSonDoc command)
        {
            // IStore interface gives you a lowlevel access to DB Structure,
              // Every action you take now will jump directly into DB without any event dispatching

              // The Istore is preloaded from densodb, and you should not have access to densodb internals.

              // Now deserialize message from Bson object.
              // should be faster using BsonObject directly but this way is more clear.
              var message = command.FromBSon<Message>();

              // Get the sender UserProfile
              var userprofile = dbstore.GetCollection("users").Where(d => d["UserName"].ToString() == message.From).FirstOrDefault().FromBSon<UserProfile>();

              if (userprofile != null)
              {
            // add message to user's messages
            var profilemessages = dbstore.GetCollection(string.Format("messages_{0}", userprofile.UserName));
            profilemessages.Set(command);

            // add message to user's wall
            var profilewall = dbstore.GetCollection(string.Format("wall_{0}", userprofile.UserName));
            profilewall.Set(command);

            // Now i have user's follower.
            foreach (var follower in userprofile.FollowedBy)
            {
              // Get followers's wall
              var followerwall = dbstore.GetCollection(string.Format("wall_{0}", follower));

              // store the messages in follower's wall.
              followerwall.Set(command);
            }
              }
        }
开发者ID:MohammadHabbab,项目名称:DensoDB,代码行数:36,代码来源:NewMessageHandler.cs

示例2: OnHandle

    public override void OnHandle(IStore store,
                                  string collection,
                                  JObject command,
                                  JObject document)
    {
      IObjectStore st = store.GetCollection(collection);

      if (document.Type == JTokenType.Array)
      {
        var documents = document.Values();
        if (documents != null)
          foreach (JObject d in documents)
          {
            var k = d.Property(DocumentMetadata.IdPropertyName);
            if (k != null)
              st.Set((string)k, d);
          }

      }
      else
      {
        var k = document.Property(DocumentMetadata.IdPropertyName);
        if (k != null)
          st.Set((string)k, document);
      }
    }
开发者ID:dronab,项目名称:DensoDB,代码行数:26,代码来源:SetManyHandler.cs

示例3: OnHandle

 public override void OnHandle(IStore store,
     string collection,
     BSonDoc command,
     BSonDoc document)
 {
     IObjectStore st = store.GetCollection(collection);
       st.Set(document);
 }
开发者ID:ppossanzini,项目名称:DensoDB,代码行数:8,代码来源:SetHandler.cs

示例4: HandleCommand

 public void HandleCommand(IStore store, BSon.BSonDoc command)
 {
     if (command.HasProperty(CommandKeyword.Collection))
       {
     var cc = store.GetCollection((command[CommandKeyword.Collection] ?? string.Empty).ToString());
     if (cc != null)
       cc.Flush();
       }
 }
开发者ID:ppossanzini,项目名称:DensoDB,代码行数:9,代码来源:CollectionFlushHandler.cs

示例5: InternalDelete

 private static void InternalDelete(BSonDoc document, string collection, IStore store)
 {
     IObjectStore st = store.GetCollection(collection);
       if (document.HasProperty(Configuration.DensoIDKeyName))
       {
     var ent = st.GetById((byte[])document[Configuration.DensoIDKeyName]);
     if (ent != null)
       st.Remove(ent);
       }
 }
开发者ID:mbsky,项目名称:DensoDB,代码行数:10,代码来源:DefaultCommandHandler.cs

示例6: HandleCommand

 public void HandleCommand(IStore store, JObject command)
 {
   var r = command.Property(CommandKeyword.Collection);
   if (r != null)
   {
     var cc = store.GetCollection(((string)r ?? string.Empty).ToString());
     if (cc != null)
       cc.Flush();
   }
 }
开发者ID:dronab,项目名称:DensoDB,代码行数:10,代码来源:CollectionFlushHandler.cs

示例7: OnHandle

 public override void OnHandle(IStore store,
                               string collection,
                               JObject command,
                               JObject document)
 {
   IObjectStore st = store.GetCollection(collection);
   if (document != null)
   {
     JToken r = document.Property(CommandKeyword.Id);
     st.Set((string)r, document);
     return;
   }
 }
开发者ID:dronab,项目名称:DensoDB,代码行数:13,代码来源:SetHandler.cs

示例8: OnHandle

        public override void OnHandle(IStore store,
            string collection,
            BSonDoc command,
            BSonDoc document)
        {
            IObjectStore st = store.GetCollection(collection);

              if (command.HasProperty(CommandKeyword.Id))
              {
            var ent = st.GetById((string)command[CommandKeyword.Id]);
            if (ent != null) st.Remove(ent);
              }

              if (document != null && document.HasProperty(DocumentMetadata.IdPropertyName))
              {
            var ent = st.GetById((string)document[DocumentMetadata.IdPropertyName]);
            if (ent != null) st.Remove(ent);
              }
        }
开发者ID:ppossanzini,项目名称:DensoDB,代码行数:19,代码来源:DeleteHandler.cs

示例9: OnHandle

        public override void OnHandle(IStore store,
                                  string collection,
                                  BSonDoc command,
                                  BSonDoc document)
        {
            if (document == null || string.IsNullOrEmpty(collection)) return;
              IObjectStore st = store.GetCollection(collection);

              if (document.DocType == BSonDocumentType.BSON_DocumentArray ||
              document.DocType == BSonDocumentType.BSON_Dictionary)
              {
            var documents = document.ToList();
            if (documents != null)
              foreach (var d in documents)
              {
            //if(d is BSonDoc && ((BSonDoc)d).HasProperty(CommandKeyword.Id))

              }
              }
        }
开发者ID:MohammadHabbab,项目名称:DensoDB,代码行数:20,代码来源:DeleteManyHandler.cs

示例10: OnHandle

        public override void OnHandle(IStore store,
                                  string collection,
                                  BSonDoc command,
                                  BSonDoc document)
        {
            if (document == null || string.IsNullOrEmpty(collection)) return;
              IObjectStore st = store.GetCollection(collection);

              if (document.HasProperty(DocumentMetadata.IdPropertyName))
              {
            UpdateSingleDocument(document, st); return;
              }

              if (document.HasProperty(CommandKeyword.Filter))
              {
            UpdateCollection(document, st); return;
              }

              st.Set(document);
        }
开发者ID:MohammadHabbab,项目名称:DensoDB,代码行数:20,代码来源:UpdateHandler.cs

示例11: OnHandle

    public override void OnHandle(IStore store,
                                  string collection,
                                  JObject command,
                                  JObject document)
    {
      if (document == null || string.IsNullOrEmpty(collection)) return;
      IObjectStore st = store.GetCollection(collection);

      var r = document.Property(DocumentMetadata.IdPropertyName);
      if (r != null)
      {
        UpdateSingleDocument(document, st); return;
      }

      var r2 = document.Property(CommandKeyword.Filter);
      if (r2 != null)
      {
        UpdateCollection(document, st); return;
      }
    }
开发者ID:dronab,项目名称:DensoDB,代码行数:20,代码来源:UpdateHandler.cs

示例12: OnHandle

        public override void OnHandle(IStore store,
                                  string collection,
                                  BSonDoc command,
                                  BSonDoc document)
        {
            IObjectStore st = store.GetCollection(collection);

              if (document.DocType == BSonDocumentType.BSON_DocumentArray ||
              document.DocType == BSonDocumentType.BSON_Dictionary)
              {
            var documents = document.ToList();
            if (documents != null)
              foreach (var d in documents)
            if (d is BSonDoc)
              st.Set(d as BSonDoc);

              }
              else
              {
            st.Set(document);
              }
        }
开发者ID:MohammadHabbab,项目名称:DensoDB,代码行数:22,代码来源:SetManyHandler.cs

示例13: OnHandle

    public override void OnHandle(IStore store,
                                  string collection,
                                  JObject command,
                                  JObject document)
    {
      IObjectStore st = store.GetCollection(collection);

      JToken r = command.Property(CommandKeyword.Id);
      if (r != null)
      {
        st.Remove((string)r);
        return;
      }

      if (document != null)
      {
        JToken r2 = document.Property(DocumentMetadata.IdPropertyName);
        if (r2 != null)
        {
          st.Remove((string)r2);
        }
      }
    }
开发者ID:dronab,项目名称:DensoDB,代码行数:23,代码来源:DeleteHandler.cs

示例14: InternalUpdate

        private static void InternalUpdate(BSonDoc document, string collection, IStore store)
        {
            IObjectStore st = store.GetCollection(collection);

              if (document.HasProperty(Configuration.DensoIDKeyName))
              {
            UpdateSingleDocument(document, st); return;
              }

              if (document.HasProperty("_filter"))
              {
            UpdateCollection(document, st); return;
              }

              InsertElement(document, st); return;
        }
开发者ID:mbsky,项目名称:DensoDB,代码行数:16,代码来源:DefaultCommandHandler.cs


注:本文中的IStore.GetCollection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。