Source/NFX.Erlang/DataAccess/SchemaMap.cs
/// <summary>
/// Maps ErlRow to CLR row supplied by schema, either Dynamic or TypedRow
/// </summary>
Maps ErlRow to CLR row supplied by schema, either Dynamic or TypedRow
Maps ErlRow to CLR row supplied by schema either Dynamic or TypedRow
public Row ErlTupleToRow(string schemaName, ErlTuple tuple, Schema schema)
    {
      var singleKey = schema.ExtraData[SCHEMA_KEY_COUNT].AsInt(0) < 2;
      var row = Row.MakeRow(schema, schema.TypedRowType);
      var i = -1;
      foreach(var elm in enumErlResponseTuple(tuple, singleKey))
      {
        i++;
        if (i==0)
        {
          var thisname = tuple[0].ValueAsString;
          if (!schemaName.EqualsOrdSenseCase(thisname))
            throw new ErlDataAccessException(StringConsts.ERL_DS_CRUD_RESP_SCH_MISMATCH_ERROR.Args(thisname, schemaName));
          continue;
        }
        if (i-1 >= schema.FieldCount)
          throw new ErlDataAccessException(StringConsts.ERL_DS_CRUD_RESP_SCH_FLD_COUNT_ERROR.Args(schemaName, schema.Name));
        var fdef = schema[i-1];
        var atr = fdef[m_Store.TargetName];
        var erlType = atr.BackendType;
        if (erlType.IsNullOrWhiteSpace())
          throw new ErlDataAccessException(StringConsts.ERL_DS_INTERNAL_MAPPING_ERROR+"fielddef('{0}') has no backend type".Args(fdef.Name));
        var clrValue = ErlToClrValue(elm, schema, fdef, m_Store.TargetName, tuple);
        row.SetFieldValue(fdef, clrValue);
      }
      return row;
    }
public Row ErlTupleToRow ( string schemaName , ErlTuple tuple , Schema schema ) { var singleKey = schema . ExtraData [ SCHEMA_KEY_COUNT ] . AsInt ( 0 ) < 2 ; var row = Row . MakeRow ( schema , schema . TypedRowType ) ; var i = - 1 ; foreach ( var elm in enumErlResponseTuple ( tuple , singleKey ) ) { i ++ ; if ( i == 0 ) { var thisname = tuple [ 0 ] . ValueAsString ; if ( ! schemaName . EqualsOrdSenseCase ( thisname ) ) throw new ErlDataAccessException ( StringConsts . ERL_DS_CRUD_RESP_SCH_MISMATCH_ERROR . Args ( thisname , schemaName ) ) ; continue ; } if ( i - 1 >= schema . FieldCount ) throw new ErlDataAccessException ( StringConsts . ERL_DS_CRUD_RESP_SCH_FLD_COUNT_ERROR . Args ( schemaName , schema . Name ) ) ; var fdef = schema [ i - 1 ] ; var atr = fdef [ m_Store . TargetName ] ; var erlType = atr . BackendType ; if ( erlType . IsNullOrWhiteSpace ( ) ) throw new ErlDataAccessException ( StringConsts . ERL_DS_INTERNAL_MAPPING_ERROR + " " . Args ( fdef . Name ) ) ; var clrValue = ErlToClrValue ( elm , schema , fdef , m_Store . TargetName , tuple ) ; row . SetFieldValue ( fdef , clrValue ) ; } return row ; }
Maps ErlRow to CLR row supplied by schema, either Dynamic or TypedRow
Maps ErlRow to CLR row supplied by schema either Dynamic or TypedRow
//map fields now
schemaName
string
tuple
ErlTuple
schema
Schema