Source/NFX/DataAccess/CRUD/RowsetBase.cs
/// <summary>
/// Reads either Table or Rowset from JSON created by WriteAsJSON.
/// </summary>
/// <returns>Total number of rows found in JSON. If this number is less than
/// result.Count, then not all rows matched the schema of the resulting rowset.</returns>
/// <remarks>
/// The schema of "result" must match the schema of the typed row T.
/// It's the responsibility of the caller to clear the "result" prior to
/// calling this function - the function appends rows to existing rowset.
/// </remarks>
Reads either Table or Rowset from JSON created by WriteAsJSON.
Reads either Table or Rowset from JSON created by WriteAsJSON .
public static int FromJSON<T>(JSONDataMap jsonMap,
                                          ref RowsetBase result,
                                          SetFieldFunc setFieldFunc = null)
              where T : TypedRow, new()
            {
              if (jsonMap == null || jsonMap.Count == 0)
                throw new CRUDException(StringConsts.ARGUMENT_ERROR + "RowsetBase.FromJSON(jsonMap=null)");
              if (result == null)
                throw new CRUDException(StringConsts.ARGUMENT_ERROR + "RowsetBase.FromJSON(result=null)");
              var typedRow = new T();
              if (result.Schema != typedRow.Schema)
                throw new CRUDException(StringConsts.ARGUMENT_ERROR + "RowsetBase.FromJSON(): invalid result schema");
              var rows = jsonMap["Rows"] as JSONDataArray;
              if (rows==null) return 0;
              foreach(var jrow in rows)
              {
                var jdo = jrow as IJSONDataObject;
                if (jdo==null)
                  continue;
                var row = new T();
                if (Row.TryFillFromJSON(row, jdo, setFieldFunc))
                  result.Add(row);
              }
              return rows.Count;
            }
public static int FromJSON < T > ( JSONDataMap jsonMap , ref RowsetBase result , SetFieldFunc setFieldFunc = null ) where T : TypedRow , new ( ) { if ( jsonMap == null || jsonMap . Count == 0 ) throw new CRUDException ( StringConsts . ARGUMENT_ERROR + " " ) ; if ( result == null ) throw new CRUDException ( StringConsts . ARGUMENT_ERROR + " " ) ; var typedRow = new T ( ) ; if ( result . Schema != typedRow . Schema ) throw new CRUDException ( StringConsts . ARGUMENT_ERROR + " " ) ; var rows = jsonMap [ " " ] as JSONDataArray ; if ( rows == null ) return 0 ; foreach ( var jrow in rows ) { var jdo = jrow as IJSONDataObject ; if ( jdo == null ) continue ; var row = new T ( ) ; if ( Row . TryFillFromJSON ( row , jdo , setFieldFunc ) ) result . Add ( row ) ; } return rows . Count ; }
Reads either Table or Rowset from JSON created by WriteAsJSON.
Reads either Table or Rowset from JSON created by WriteAsJSON .
Total number of rows found in JSON. If this number is less than
result.Count, then not all rows matched the schema of the resulting rowset.
Total number of rows found in JSON . If this number is less than result . Count then not all rows matched the schema of the resulting rowset .
jsonMap
JSONDataMap
RowsetBase
ref
setFieldFunc
SetFieldFunc
remarks
The schema of "result" must match the schema of the typed row T.
It's the responsibility of the caller to clear the "result" prior to
calling this function - the function appends rows to existing rowset.
The schema of " result " must match the schema of the typed row T . It ' s the responsibility of the caller to clear the " result " prior to calling this function - the function appends rows to existing rowset .