Source/NFX/Serialization/BSON/RowConverter.cs
/// <summary>
/// Converts row to BSON document suitable for storage in MONGO.DB.
/// Pass target name (name of particular store/epoch/implementation) to get targeted field metadata.
/// Note: the supplied row MAY NOT CONTAIN REFERENCE CYCLES - either direct or transitive
/// </summary>
Converts row to BSON document suitable for storage in MONGO.DB.
Pass target name (name of particular store/epoch/implementation) to get targeted field metadata.
Converts row to BSON document suitable for storage in MONGO . DB . Pass target name ( name of particular store / epoch / implementation ) to get targeted field metadata .
public virtual BSONDocumentElement RowToBSONDocumentElement(Row row, string targetName, bool useAmorphousData = true, string name= null, FieldFilterFunc filter = null)
      {
        if (row==null) return null;
        var amrow = row as IAmorphousData;
        if (amrow!=null && useAmorphousData && amrow.AmorphousDataEnabled)
        {
            amrow.BeforeSave(targetName);
        }
        var result = new BSONDocument();
        foreach(var field in row.Schema)
        {
            var attr = field[targetName];
            if (attr!=null && attr.StoreFlag!=StoreFlag.OnlyStore && attr.StoreFlag!=StoreFlag.LoadAndStore) continue;
            if (filter!=null)
            {
              if (!filter(row, null, field)) continue;
            }
            var el = GetFieldAsBSON(row, field, targetName);
            result.Set( el );
        }
        if (amrow!=null && useAmorphousData && amrow.AmorphousDataEnabled)
          foreach(var kvp in amrow.AmorphousData)
          {
            result.Set( GetAmorphousFieldAsBSON(kvp, targetName) );
          }
        return name != null ? new BSONDocumentElement(name, result) : new BSONDocumentElement(result);
      }
public virtual BSONDocumentElement RowToBSONDocumentElement ( Row row , string targetName , bool useAmorphousData = true , string name = null , FieldFilterFunc filter = null ) { if ( row == null ) return null ; var amrow = row as IAmorphousData ; if ( amrow != null && useAmorphousData && amrow . AmorphousDataEnabled ) { amrow . BeforeSave ( targetName ) ; } var result = new BSONDocument ( ) ; foreach ( var field in row . Schema ) { var attr = field [ targetName ] ; if ( attr != null && attr . StoreFlag != StoreFlag . OnlyStore && attr . StoreFlag != StoreFlag . LoadAndStore ) continue ; if ( filter != null ) { if ( ! filter ( row , null , field ) ) continue ; } var el = GetFieldAsBSON ( row , field , targetName ) ; result . Set ( el ) ; } if ( amrow != null && useAmorphousData && amrow . AmorphousDataEnabled ) foreach ( var kvp in amrow . AmorphousData ) { result . Set ( GetAmorphousFieldAsBSON ( kvp , targetName ) ) ; } return name != null ? new BSONDocumentElement ( name , result ) : new BSONDocumentElement ( result ) ; }
Converts row to BSON document suitable for storage in MONGO.DB.
Converts row to BSON document suitable for storage in MONGO . DB .
//20160210 Dkh+SPol
row
Row
targetName
string
useAmorphousData
bool
name
string
filter
FieldFilterFunc