public object ParseResult(object[] values) { var obj = Activator.CreateInstance(Table.ModelType); for (var i = 0; i < _columns.Count; i++) { var col = _columns[i]; var val = PgTypesConverter.ConvertFromRawSqlValue(col.Type, values[i]); col.PropertyInfo.SetValue(obj, val); } return(obj); }
public object ParseResult(object[] values) { object[] constructorParams = new object[Entries.Count]; int columnIdx = 0; for (var i = 0; i < Entries.Count; i++) { var entry = Entries[i]; if (entry.MemberPgTable != null) { var table = entry.MemberPgTable; var isNull = (bool)PgTypesConverter.ConvertFromRawSqlValue(KDPgValueTypeInstances.Boolean, values[columnIdx++]); if (isNull) { constructorParams[i] = null; columnIdx += table.Columns.Count; } else { var modelObj = Activator.CreateInstance(table.ModelType); foreach (var column in table.Columns) { var val = PgTypesConverter.ConvertFromRawSqlValue(column.Type, values[columnIdx++]); column.PropertyInfo.SetValue(modelObj, val); } constructorParams[i] = modelObj; } } else if (entry.MemberPgType != null) { constructorParams[i] = PgTypesConverter.ConvertFromRawSqlValue(entry.MemberPgType, values[columnIdx++]); } else { throw new Exception(); } } return(Activator.CreateInstance(typeof(TModel), constructorParams)); }
public object ParseResult(object[] values) { var obj = Activator.CreateInstance(Table.ModelType); var isNull = (bool)PgTypesConverter.ConvertFromRawSqlValue(KDPgValueTypeInstances.Boolean, values[0]); if (isNull) { return(null); } for (var i = 0; i < _columns.Count; i++) { var col = _columns[i]; var val = PgTypesConverter.ConvertFromRawSqlValue(col.Type, values[1 + i]); col.PropertyInfo.SetValue(obj, val); } return(obj); }
public object ParseResult(object[] values) { return(PgTypesConverter.ConvertFromRawSqlValue(_type, values[0])); }