New option/callback MergeDuplicateReturnModels
If a stored proc has any type of a If-Else statement in it the tool reads it as having 2 resultsets. It's Sql Server that tells the generator there will be 2 result sets.
I was thinking that if both result sets are identical, then they could be merged into one, but the risk here is, if a stored procedure does in fact return two lots of differing data with the same model, which is valid and quite efficient. So therefore I cannot merge them without concequences for others.
Therefore I need to create a new option or a callback, to say MergeDuplicateReturnModels.
Hello, I have lots of stored procedures that does SELECT ... UNION ... and so on.
This is an issue as the FMTONLY ON returns 3 result sets, so there is not the tool's fault, but rather sql server.
However I have a solution for that, but the solution cannot be radical so that it excludes all additional result sets because in some procedures I want to use them.
My compromise solution there is to check if a resultset with exactly same set of columns is added to the sproc.ReturnObjects collection, and in this case skip it.
In FIle: EF.Reverse.POCO.CORE.ttinclude
Method: public void ReadStoredProcReturnObject(SqlConnection sqlConnection, StoredProcedure proc)Starts on Line 2809 for me.
After commented line: // Tidy up parameters and the loop for parameters, I added this
System.Collections.Generic.List<string> aHash = new System.Collections.Generic.List<string>();
Then in the right next for that loops the dataset tables read by schema sql adapter,
I replaced proc.ReturnModels.Add( .... )
with this:
List<DataColumn> aList= ds.Tables[count].Columns.Cast<DataColumn>().ToList();
string identifier = "";
// Build the returnmodel identifier just appending all columnnames
foreach ( DataColumn aColumn in aList) {
identifier = identifier + aColumn.ColumnName;
}
// Add to return models and to my hashed list ONLY if there is not already there.
if ( !aHash.Contains(identifier)) {
aHash.Add(identifier);
proc.ReturnModels.Add(aList);
}
Thank you.