/// <summary> /// Constructs instance of SqlResults. /// </summary> internal SqlResults() { this.Result = StoreResult.Success; _ssm = new List <IStoreShardMap>(); _ss = new List <IStoreShard>(); _sm = new List <IStoreMapping>(); _sl = new List <IStoreLocation>(); _si = new List <IStoreSchemaInfo>(); _version = null; _ops = new List <IStoreLogEntry>(); }
/// <summary> /// Constructs instance of SqlResults. /// </summary> internal SqlResults() { this.Result = StoreResult.Success; _ssm = new List<IStoreShardMap>(); _ss = new List<IStoreShard>(); _sm = new List<IStoreMapping>(); _sl = new List<IStoreLocation>(); _si = new List<IStoreSchemaInfo>(); _version = null; _ops = new List<IStoreLogEntry>(); }
/// <summary> /// Asynchronously populates instance of SqlResults using rows from SqlDataReader. /// </summary> /// <param name="reader">SqlDataReader whose rows are to be read.</param> /// <returns>A task to await read completion</returns> internal async Task FetchAsync(SqlDataReader reader) { Func <Action, Task> ReadAsync = async(readAction) => { while (await reader.ReadAsync().ConfigureAwait(false)) { readAction(); } }; do { if (reader.FieldCount > 0) { SqlResultType resultType = SqlResults.SqlResultTypeFromColumnName(reader.GetName(1)); switch (resultType) { case SqlResultType.ShardMap: await ReadAsync(() => _ssm.Add(new SqlShardMap(reader, 1))).ConfigureAwait(false); break; case SqlResultType.Shard: await ReadAsync(() => _ss.Add(new SqlShard(reader, 1))).ConfigureAwait(false); break; case SqlResultType.ShardMapping: await ReadAsync(() => _sm.Add(new SqlMapping(reader, 1))).ConfigureAwait(false); break; case SqlResultType.ShardLocation: await ReadAsync(() => _sl.Add(new SqlLocation(reader, 1))).ConfigureAwait(false); break; case SqlResultType.SchemaInfo: await ReadAsync(() => _si.Add(new SqlSchemaInfo(reader, 1))).ConfigureAwait(false); break; case SqlResultType.StoreVersion: await ReadAsync(() => _version = new SqlVersion(reader, 1)).ConfigureAwait(false); break; case SqlResultType.Operation: await ReadAsync(() => _ops.Add(new SqlLogEntry(reader, 1))).ConfigureAwait(false); break; default: // This code is unreachable, since the all values of the SqlResultType enum are explicitly handled above. Debug.Assert(false); break; } } }while (await reader.NextResultAsync().ConfigureAwait(false)); }
/// <summary> /// Populates instance of SqlResults using rows from SqlDataReader. /// </summary> /// <param name="reader">SqlDataReader whose rows are to be read.</param> internal void Fetch(SqlDataReader reader) { do { if (reader.FieldCount > 0) { SqlResultType resultType = SqlResults.SqlResultTypeFromColumnName(reader.GetName(1)); switch (resultType) { case SqlResultType.ShardMap: while (reader.Read()) { _ssm.Add(new SqlShardMap(reader, 1)); } break; case SqlResultType.Shard: while (reader.Read()) { _ss.Add(new SqlShard(reader, 1)); } break; case SqlResultType.ShardMapping: while (reader.Read()) { _sm.Add(new SqlMapping(reader, 1)); } break; case SqlResultType.ShardLocation: while (reader.Read()) { _sl.Add(new SqlLocation(reader, 1)); } break; case SqlResultType.SchemaInfo: while (reader.Read()) { _si.Add(new SqlSchemaInfo(reader, 1)); } break; case SqlResultType.StoreVersion: while (reader.Read()) { _version = new SqlVersion(reader, 1); } break; case SqlResultType.Operation: while (reader.Read()) { _ops.Add(new SqlLogEntry(reader, 1)); } break; default: // This code is unreachable, since the all values of the SqlResultType enum are explicitly handled above. Debug.Assert(false); break; } } }while (reader.NextResult()); }
/// <summary> /// Asynchronously populates instance of SqlResults using rows from SqlDataReader. /// </summary> /// <param name="reader">SqlDataReader whose rows are to be read.</param> /// <returns>A task to await read completion</returns> internal async Task FetchAsync(SqlDataReader reader) { Func<Action, Task> ReadAsync = async (readAction) => { while (await reader.ReadAsync()) { readAction(); } }; do { if (reader.FieldCount > 0) { SqlResultType resultType = SqlResults.SqlResultTypeFromColumnName(reader.GetSchemaTable().Rows[1]["ColumnName"].ToString()); switch (resultType) { case SqlResultType.ShardMap: await ReadAsync(() => _ssm.Add(new SqlShardMap(reader, 1))); break; case SqlResultType.Shard: await ReadAsync(() => _ss.Add(new SqlShard(reader, 1))); break; case SqlResultType.ShardMapping: await ReadAsync(() => _sm.Add(new SqlMapping(reader, 1))); break; case SqlResultType.ShardLocation: await ReadAsync(() => _sl.Add(new SqlLocation(reader, 1))); break; case SqlResultType.SchemaInfo: await ReadAsync(() => _si.Add(new SqlSchemaInfo(reader, 1))); break; case SqlResultType.StoreVersion: await ReadAsync(() => _version = new SqlVersion(reader, 1)); break; case SqlResultType.Operation: await ReadAsync(() => _ops.Add(new SqlLogEntry(reader, 1))); break; default: // This code is unreachable, since the all values of the SqlResultType enum are explicitly handled above. Debug.Assert(false); break; } } } while (await reader.NextResultAsync()); }
/// <summary> /// Populates instance of SqlResults using rows from SqlDataReader. /// </summary> /// <param name="reader">SqlDataReader whose rows are to be read.</param> internal void Fetch(SqlDataReader reader) { do { if (reader.FieldCount > 0) { SqlResultType resultType = SqlResults.SqlResultTypeFromColumnName(reader.GetSchemaTable().Rows[1]["ColumnName"].ToString()); switch (resultType) { case SqlResultType.ShardMap: while (reader.Read()) { _ssm.Add(new SqlShardMap(reader, 1)); } break; case SqlResultType.Shard: while (reader.Read()) { _ss.Add(new SqlShard(reader, 1)); } break; case SqlResultType.ShardMapping: while (reader.Read()) { _sm.Add(new SqlMapping(reader, 1)); } break; case SqlResultType.ShardLocation: while (reader.Read()) { _sl.Add(new SqlLocation(reader, 1)); } break; case SqlResultType.SchemaInfo: while (reader.Read()) { _si.Add(new SqlSchemaInfo(reader, 1)); } break; case SqlResultType.StoreVersion: while (reader.Read()) { _version = new SqlVersion(reader, 1); } break; case SqlResultType.Operation: while (reader.Read()) { _ops.Add(new SqlLogEntry(reader, 1)); } break; default: // This code is unreachable, since the all values of the SqlResultType enum are explicitly handled above. Debug.Assert(false); break; } } } while (reader.NextResult()); }