Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mikependon opened this issue Sep 22, 2020 · 2 comments
Assignees
Labels
deployed Feature or bug is deployed at the current release fixed The bug, issue, incident has been fixed. request A request from the community.

Comments

@mikependon
Copy link
Owner

mikependon commented Sep 22, 2020

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

@mikependon mikependon added the request A request from the community. label Sep 22, 2020
@mikependon mikependon self-assigned this Sep 22, 2020
@mikependon mikependon pinned this issue Sep 22, 2020
@mikependon mikependon changed the title Request: Add the 'isMoveToNextResult' argument to the QueryMultipleExtractor (Extract and Scalar) Request: Add the 'isMoveToNextResult' argument to the QueryMultipleExtractor (Extract and Scalar) methods Sep 22, 2020
@mikependon mikependon added the fixed The bug, issue, incident has been fixed. label Sep 22, 2020
@mikependon mikependon unpinned this issue Sep 22, 2020
@mikependon
Copy link
Owner Author

This is now available at RepoDb v1.12.0.

@mikependon mikependon added the deployed Feature or bug is deployed at the current release label Sep 24, 2020
@mikependon
Copy link
Owner Author

This has been fixed and is now available at RepoDb v1.12.3. Closing this incident ticket now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed Feature or bug is deployed at the current release fixed The bug, issue, incident has been fixed. request A request from the community.
Projects
None yet
Development

No branches or pull requests

1 participant