Source/NFX.Erlang/DataAccess/SchemaMap.cs
/// <summary>
/// Converts CLR row data into ErlTuple
/// </summary>
Converts CLR row data into ErlTuple
Converts CLR row data into ErlTuple
public ErlTuple RowToErlTuple(Row row, bool keysOnly = false)
    {
      var result = new ErlTuple();
      result.Add(new ErlAtom(row.Schema.Name));
      var keys = new List<IErlObject>();
      foreach(var def in row.Schema)
      {
        var atr = def[m_Store.TargetName];
        if (keysOnly && !atr.Key) break;
        if (keys!=null && !atr.Key)
        {
          if (keys.Count>1)
            result.Add( new ErlTuple(keys, false) );
          else
            foreach(var key in keys) result.Add( key );
          keys = null;
        }
        IErlObject erlValue = ErlAtom.Undefined;
        var clrValue = row.GetFieldValue(def);
        if (clrValue!=null)
          erlValue = ClrToErlValue(atr.BackendType, clrValue);
        if (keys!=null)
          keys.Add( erlValue );
        else
          result.Add( erlValue );
      }
      if (keys!=null)
      {
        if (keys.Count>1)
         result.Add( new ErlTuple(keys, false) );
        else
         foreach(var key in keys) result.Add( key );
      }
      return result;
    }
public ErlTuple RowToErlTuple ( Row row , bool keysOnly = false ) { var result = new ErlTuple ( ) ; result . Add ( new ErlAtom ( row . Schema . Name ) ) ; var keys = new List < IErlObject > ( ) ; foreach ( var def in row . Schema ) { var atr = def [ m_Store . TargetName ] ; if ( keysOnly && ! atr . Key ) break ; if ( keys != null && ! atr . Key ) { if ( keys . Count > 1 ) result . Add ( new ErlTuple ( keys , false ) ) ; else foreach ( var key in keys ) result . Add ( key ) ; keys = null ; } IErlObject erlValue = ErlAtom . Undefined ; var clrValue = row . GetFieldValue ( def ) ; if ( clrValue != null ) erlValue = ClrToErlValue ( atr . BackendType , clrValue ) ; if ( keys != null ) keys . Add ( erlValue ) ; else result . Add ( erlValue ) ; } if ( keys != null ) { if ( keys . Count > 1 ) result . Add ( new ErlTuple ( keys , false ) ) ; else foreach ( var key in keys ) result . Add ( key ) ; } return result ; }
Converts CLR row data into ErlTuple
Converts CLR row data into ErlTuple
row
Row
keysOnly
bool