public static StatementResult CreateResultSet(IEnumerable <Tuple <V1.Type, string> > columns, IEnumerable <object[]> rows) { var rs = new ResultSet { Metadata = new ResultSetMetadata { RowType = new StructType() }, }; foreach (var col in columns) { rs.Metadata.RowType.Fields.Add(new StructType.Types.Field { Type = col.Item1, Name = col.Item2, }); } foreach (var rowValue in rows) { var row = new ListValue(); var colIndex = 0; foreach (var value in rowValue) { row.Values.Add(SpannerConverter.ToProtobufValue(rs.Metadata.RowType.Fields[colIndex].Type, value)); colIndex++; } rs.Rows.Add(row); } return(CreateQuery(rs)); }
internal static StatementResult CreateSingleColumnResultSet(V1.Type type, string col, params object[] values) { ResultSet rs = new ResultSet { Metadata = new ResultSetMetadata { RowType = new StructType() }, }; rs.Metadata.RowType.Fields.Add(new StructType.Types.Field { Name = col, Type = type, }); foreach (object val in values) { ListValue row = new ListValue(); row.Values.Add(SpannerConverter.ToProtobufValue(type, val)); rs.Rows.Add(row); } return(CreateQuery(rs)); }