コード例 #1
0
ファイル: Query.cs プロジェクト: dotnetchris/nfx
        public static Query ID_EQ_GDID(GDID id)
        {
            var result = new Query();

            result.Set(NFX.Serialization.BSON.RowConverter.GDID_CLRtoBSON(_ID, id));
            return(result);
        }
コード例 #2
0
ファイル: Query.cs プロジェクト: dotnetchris/nfx
        public static Query ID_EQ_BYTE_ARRAY(byte[] id)
        {
            var result = new Query();

            result.Set(NFX.Serialization.BSON.RowConverter.ByteBufferID_CLRtoBSON(_ID, id));
            return(result);
        }
コード例 #3
0
ファイル: Query.cs プロジェクト: dotnetchris/nfx
        public static Query ID_EQ_Int32(Int64 id)
        {
            var result = new Query();

            result.Set(new BSONInt64Element(_ID, id));
            return(result);
        }
コード例 #4
0
ファイル: MongoDBDataStore.cs プロジェクト: cyecp/nfx
        protected virtual int DoUpdate(Connector.Database db, Row row, IDataStoreKey key, FieldFilterFunc filter = null)
        {
            var doc = convertRowToBSONDocumentWith_ID(row, "update", filter);
            var _id = doc[Connector.Protocol._ID];

            doc.Delete(Connector.Protocol._ID);
            if (doc.Count == 0)
            {
                return(0);              // nothing to update
            }
            //20160212 spol
            if (filter != null)
            {
                var wrapDoc = new BSONDocument();
                wrapDoc.Set(new BSONDocumentElement(Connector.Protocol.SET, doc));
                doc = wrapDoc;
            }

            var tname = GetCollectionName(row.Schema);

            var collection = db[tname];

            var qry = new Connector.Query();

            qry.Set(_id);
            var upd = new Connector.UpdateEntry(qry, doc, false, false);

            var result = collection.Update(upd);

            CheckCRUDResult(result, row.Schema.Name, "update");

            return(result.TotalDocumentsAffected);
        }
コード例 #5
0
ファイル: Query.cs プロジェクト: vlapchenko/nfx
    public static Query ID_EQ_String(string id)
    {
      if (id==null)
       throw new MongoDBConnectorException(StringConsts.ARGUMENT_ERROR+"ID_EQ_String(id==null)");

      var result = new Query();
      result.Set( new BSONStringElement(_ID, id) );
      return result;
    }
コード例 #6
0
ファイル: Query.cs プロジェクト: dotnetchris/nfx
        public static Query ID_EQ_String(string id)
        {
            if (id == null)
            {
                throw new MongoDBConnectorException(StringConsts.ARGUMENT_ERROR + "ID_EQ_String(id==null)");
            }

            var result = new Query();

            result.Set(new BSONStringElement(_ID, id));
            return(result);
        }
コード例 #7
0
ファイル: MongoDBDataStore.cs プロジェクト: cyecp/nfx
        protected virtual int DoDelete(Connector.Database db, Row row, IDataStoreKey key)
        {
            var doc = convertRowToBSONDocumentWith_ID(row, "delete");

            var tname = GetCollectionName(row.Schema);

            var collection = db[tname];

            var qry = new Connector.Query();

            qry.Set(doc[Connector.Protocol._ID]);

            var result = collection.Delete(new Connector.DeleteEntry(qry, Connector.DeleteLimit.OnlyFirstMatch));

            CheckCRUDResult(result, row.Schema.Name, "delete");

            return(result.TotalDocumentsAffected);
        }
コード例 #8
0
        protected virtual int DoUpdate(Connector.Database db, Row row, IDataStoreKey key)
        {
            var doc = convertRowToBSONDocumentWith_ID(row, "update");

            var tname = GetCollectionName(row.Schema);

            var collection = db[tname];

            var qry = new Connector.Query();

            qry.Set(doc[Connector.Protocol._ID]);
            var upd = new Connector.UpdateEntry(qry, doc, false, false);

            var result = collection.Update(upd);

            checkCRUDResult(result, row.Schema.Name, "update");

            return(result.TotalDocumentsAffected);
        }
コード例 #9
0
ファイル: Query.cs プロジェクト: vlapchenko/nfx
 public static Query ID_EQ_GDID(GDID id)
 {
   var result = new Query();
   result.Set( NFX.Serialization.BSON.RowConverter.GDID_CLRtoBSON(_ID, id) );
   return result;
 }
コード例 #10
0
ファイル: Query.cs プロジェクト: vlapchenko/nfx
 public static Query ID_EQ_Int32(Int64 id)
 {
   var result = new Query();
   result.Set( new BSONInt64Element(_ID, id) );
   return result;
 }
コード例 #11
0
ファイル: MongoDBDataStore.cs プロジェクト: vlapchenko/nfx
        protected virtual int DoDelete(Connector.Database db, Row row, IDataStoreKey key)
        {
          var doc = convertRowToBSONDocumentWith_ID(row, "delete");
          
          var tname = GetCollectionName(row.Schema);
          
          var collection = db[tname]; 
          
          var qry = new Connector.Query();
          qry.Set( doc[Connector.Protocol._ID] );

          var result = collection.Delete( new Connector.DeleteEntry( qry, Connector.DeleteLimit.OnlyFirstMatch) );
         
          checkCRUDResult(result, row.Schema.Name, "delete");

          return result.TotalDocumentsAffected;
        }
コード例 #12
0
ファイル: MongoDBDataStore.cs プロジェクト: vlapchenko/nfx
        protected virtual int DoUpdate(Connector.Database db, Row row, IDataStoreKey key)
        {
          var doc = convertRowToBSONDocumentWith_ID(row, "update");
          
          var tname = GetCollectionName(row.Schema);
          
          var collection = db[tname]; 
          
          var qry = new Connector.Query();
          qry.Set( doc[Connector.Protocol._ID] );
          var upd = new Connector.UpdateEntry(qry, doc, false, false);

          var result = collection.Update( upd );

          checkCRUDResult(result, row.Schema.Name, "update");

          return result.TotalDocumentsAffected;
        }
コード例 #13
0
ファイル: Query.cs プロジェクト: itadapter/nfx
 public static Query ID_EQ_BYTE_ARRAY(byte[] id)
 {
     var result = new Query();
       result.Set( NFX.Serialization.BSON.RowConverter.ByteBufferID_CLRtoBSON(_ID, id) );
       return result;
 }
コード例 #14
0
ファイル: MongoDBDataStore.cs プロジェクト: itadapter/nfx
        protected virtual int DoUpdate(Connector.Database db, Row row, IDataStoreKey key, FieldFilterFunc filter = null)
        {
            var doc = convertRowToBSONDocumentWith_ID(row, "update", filter);
              var _id = doc[Connector.Protocol._ID];

              //20160212 spol
              if (filter != null)
              {
            doc.Delete(Connector.Protocol._ID);
            if (doc.Count == 0) return 0; // nothing to update
            var wrapDoc = new BSONDocument();
            wrapDoc.Set(new BSONDocumentElement(Connector.Protocol.SET, doc));
            doc = wrapDoc;
              }

              var tname = GetCollectionName(row.Schema);

              var collection = db[tname];

              var qry = new Connector.Query();
              qry.Set( _id );
              var upd = new Connector.UpdateEntry(qry, doc, false, false);

              var result = collection.Update( upd );

              checkCRUDResult(result, row.Schema.Name, "update");

              return result.TotalDocumentsAffected;
        }