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

Merge duplicate multiple result sets #37

Closed
sjh37 opened this issue May 5, 2016 · 10 comments
Closed

Merge duplicate multiple result sets #37

sjh37 opened this issue May 5, 2016 · 10 comments

Comments

@sjh37
Copy link
Owner

sjh37 commented May 5, 2016

If a stored procedure contains conditional statements, such as this:

IF(@someVar < @otherVar) BEGIN
   SELECT a,b,c WHERE blah
ELSE
   SELECT a,b,c WHERE blah OR blah
END

The result sets will be the same, even though two can be returned.
Instead of including ResultSet1 and ResultSet2, these can be merged and instead use a single return model.

@youngcm2
Copy link

+1

@youngcm2
Copy link

Or it would be nice to specify in the tt to only return 1 result set for procs.

@jvinkovic
Copy link

jvinkovic commented Jul 11, 2017

Any update on this?? Or, can be specified in tt to include only first one?

@aplocher
Copy link

+1

@jvinkovic
Copy link

I resolved it in a way that always first set is taken if specified in tt file. Will make a pull request in a month.

@jasonklinke
Copy link

Any updated workaround for this? The only thing I've found to work reliably is to just separate my stored procedure that contains IF/ELSE SELECTs into separate stored procedures that map to the same result set entity, but that's not ideal...

@sjh37
Copy link
Owner Author

sjh37 commented Apr 10, 2018

I fully understand. It's actually SQL Server that tells me what will be returned, and where there are conditionals, for some reason it tells me there will be two or more result sets returned, even though in reality there could be only one.

As some results sets returned may be identical, they could in fact contain valid data. So what will happen is I will add an array to the settings you can edit so you can opt in certain stored procs to be merged if you know that is safe to do so.

Time scales - This is low priority, and will happen sometime after I have completed adding support for EF .Net Core version. Another biggie, is to add support for Oracle, MySql, Postgres, etc. However, I don't mind injecting quick wins into the generator, which this one would be. However, I've promised everyone that I'm concentrating on EF core support.

@jasonklinke
Copy link

Understood, thanks for the quick reply. And I realize that you're just dealing with whatever SQL Server tells you about the stored procedure. It's unfortunate that SQL Server appears to be wrong in this case. The setting addition to merge result sets for specific stored procedures would be great. In the meantime, at least there are some other ways to workaround the issue.

@CorsairRO
Copy link

hello,

please find my temporary solute that I presented in Issue #265

@sjh37
Copy link
Owner Author

sjh37 commented Dec 18, 2023

I have included a new setting flag which defaults to true. This will cause the generator to inspect multiple result sets to see if they are all identical. If they are all identical the duplicates will be removed leaving a single model.

Settings.MergeMultipleStoredProcModelsIfAllSame = true;

This will be in the next release.

@sjh37 sjh37 closed this as completed Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants