Skip to content

Request: Add the 'isMoveToNextResult' argument to the QueryMultipleExtractor (Extract and Scalar) methods #591

@mikependon

Description

@mikependon

As requested by the community, we need to add an additional argument to the Extract and Scalar method of the QueryMultipleExtractor class.

The call below is moving to the next result after calling the Extract.

using (var connection = new SqlConnection(connectionString))
{
	var commandText = "SELECT Id, Name FROM [dbo].[Customer] WHERE Id = @CustomerId; SELECT * FROM [dbo].[Order] WHERE CustomerId = @CustomerId;";

	using (var extractor = connection.ExecuteQueryMultiple(commandText, new { CustomerId = 10045 }))
	{
		var customer = extractor.Extract<Customer>().FirstOrDefault(); // <-- This does not moves to the next result
		var orders = extractor.Extract<Order>().AsList(); // <-- In the 2nd position
		
		// Do the stuffs for the 'customer' and 'orders' here
	}
}

By passing a value of false to the argument isMoveToNextResult, then the data reader will not move the pointer.

using (var connection = new SqlConnection(connectionString))
{
	var commandText = "SELECT Id, Name FROM [dbo].[Customer] WHERE Id = @CustomerId; SELECT * FROM [dbo].[Order] WHERE CustomerId = @CustomerId;";

	using (var extractor = connection.ExecuteQueryMultiple(commandText, new { CustomerId = 10045 }))
	{
		var customer = extractor.Extract<Customer>(false).FirstOrDefault(); // <-- This moves to the next result
		extractor.NextResult(); // <-- Manually moving to the next result
		var orders = extractor.Extract<Order>().AsList(); // <-- In the 2nd position
		
		// Do the stuffs for the 'customer' and 'orders' here
	}
}

The same scenario is the same for the Scalar method, and also to their corresponding Async methods. FYI: @cleverguy25

Metadata

Metadata

Assignees

Labels

deployedFeature or bug is deployed at the current releasefixedThe bug, issue, incident has been fixed.requestA request from the community.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions