/// <summary> /// Parse the results of a sql query which returns one column /// </summary> /// <param name="rows">The query results</param> /// <param name="propertyGraph">The query columns mapped to an object graph</param> static IEnumerable <TResult> ParseSimple <TResult>(this IEnumerable <object[]> rows, RootObjectPropertyGraph propertyGraph, ILogger logger) { var propMapBuilder = new PropMapValueCache <TResult>(logger); foreach (var value in rows.ParseComplex <PropMapValue <TResult> >(propertyGraph, logger, propMapBuilder)) { yield return(value.Value); value.Dispose(); } }
/// <summary> /// Parse the results of a sql query which returns a comlex object /// </summary> /// <param name="rows">The query results</param> /// <param name="propertyGraph">The query columns mapped to an object graph</param> static IEnumerable <TResult> ParseComplex <TResult>(this IEnumerable <object[]> rows, RootObjectPropertyGraph propertyGraph, ILogger logger, IPropMapValueCache propMapBuilder) { var objectGraphCache = new ObjectGraphCache(logger); var builder = Builders.GetBuilder <TResult>(); foreach (var obj in CreateObject(propertyGraph, objectGraphCache, rows, logger)) { var result = builder.Build(obj, propMapBuilder, logger); obj.Dispose(); yield return(result); } }
/// <summary> /// Parse the results of a sql query /// </summary> /// <param name="rows">The query results</param> /// <param name="propertyGraph">The query columns mapped to an object graph</param> internal static IEnumerable <TResult> Parse <TResult>(this IEnumerable <object[]> rows, RootObjectPropertyGraph propertyGraph, ILogger logger, bool requiresSimpleValueUnwrap) { return(requiresSimpleValueUnwrap ? ParseSimple <TResult>(rows, propertyGraph, logger) : ParseComplex <TResult>(rows, propertyGraph, logger, InvalidPropValueCache.Instance)); }