private async Task<ExecuteReaderOperationInfo> LoadSchemaAsync(SqlDatabaseObjectName procedure, ISqlProcedureSelector selector) { var info = new ExecuteReaderOperationInfo(); using (var command = new SqlCommand()) { command.CommandText = procedure.FullName; command.CommandType = CommandType.StoredProcedure; this.m_session.DeriveParameters(command); foreach (SqlParameter parameter in command.Parameters) { info.Parameters.Add(new SqlParameterInfo(parameter)); } var dataSet = new DataSet(); var schemaTables = this.m_session.FillSchema(command, dataSet, SchemaType.Source); for(int resultSetIndex = 0; resultSetIndex <schemaTables.Length; ++resultSetIndex) { var schema = schemaTables[resultSetIndex]; var mappings = selector.GetResultSetMappings(resultSetIndex)?.ToList(); var currentResultSet = this.BuildResultSetInfo(schema, mappings); var previousResultSet = info.ResultSetInfos.LastOrDefault(); info.ResultSetInfos.Add(currentResultSet); if (ReferenceEquals(previousResultSet, null) == false) { previousResultSet.Next = currentResultSet; } } } return info; }
private async Task<ExecuteReaderOperationInfo> BuildExecuteReaderOperationInfoAsync( ISqlProcedureSelector selector, SqlDatabaseObjectName procedure) { var loadSchemaTask = this.LoadSchemaAsync(procedure, selector); var interfaceNames = new HashSet<string>(); for (int resultSetIndex = 0; resultSetIndex < selector.ResultSetsCount; ++resultSetIndex) { var mappings = selector.GetResultSetMappings(resultSetIndex); foreach (var interfaceName in mappings.Select(m => m.InterfaceName)) { interfaceNames.Add(interfaceName); } } var operationInfo = await loadSchemaTask; operationInfo.InterfaceNames.AddRange(interfaceNames); return operationInfo; }