Skip to content

Commit d082d5b

Browse files
committed
#198. Pass in the StoredProcedure class to StoredProcedureRename instead of the name. Thanks to ichalyshev
1 parent c377942 commit d082d5b

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

EntityFramework.Reverse.POCO.Generator/Database NorthwindSqlCe40.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@
365365
// That's it, nothing else to configure ***********************************************************************************************
366366

367367
// Stored procedure are not supported in SqlCE - create dummy functions
368-
StoredProcedureRename = (name, schema) => name;
368+
StoredProcedureRename = (sp) => sp.NameHumanCase;
369369
Func<StoredProcedure, string> WriteStoredProcFunctionName = null;
370370
Func<StoredProcedure, bool> StoredProcHasOutParams = null;
371371
Func<StoredProcedure, bool, string> WriteStoredProcFunctionParams = null;

EntityFramework.Reverse.POCO.Generator/Database.tt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,13 @@
241241
// StoredProcedure renaming ************************************************************************************************************
242242
// Use the following function to rename stored procs such as sp_CreateOrderHistory to CreateOrderHistory, my_sp_shipments to Shipments, etc.
243243
// Example:
244-
/*StoredProcedureRename = (name, schema) =>
244+
/*StoredProcedureRename = (sp) =>
245245
{
246-
if (name.StartsWith("sp_"))
247-
name = name.Remove(0, 3);
248-
return name.Replace("my_sp_", "");
246+
if (sp.NameHumanCase.StartsWith("sp_"))
247+
return sp.NameHumanCase.Remove(0, 3);
248+
return sp.NameHumanCase.Replace("my_sp_", "");
249249
};*/
250-
StoredProcedureRename = (name, schema) => name; // Do nothing by default
250+
StoredProcedureRename = (sp) => sp.NameHumanCase; // Do nothing by default
251251

252252
// Use the following function to rename the return model automatically generated for stored procedure.
253253
// By default it's <proc_name>ReturnModel.

EntityFramework.Reverse.POCO.Generator/EF.Reverse.POCO.Core.ttinclude

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
private string _providerName = "";
8787
private string _configFilePath = "";
8888
Func<string, string, string> TableRename;
89-
Func<string, string, string> StoredProcedureRename;
89+
Func<StoredProcedure, string> StoredProcedureRename;
9090
static Func<string, StoredProcedure, string> StoredProcedureReturnModelRename;
9191
Func<Column, Table, Column> UpdateColumn;
9292
Func<ForeignKey, ForeignKey> ForeignKeyFilter;
@@ -1483,7 +1483,7 @@
14831483

14841484
public GeneratedTextTransformation Outer;
14851485
public abstract Tables ReadSchema(Regex schemaFilterExclude, Regex schemaFilterInclude, Regex tableFilterExclude, Regex tableFilterInclude, Regex columnFilterExclude, Func<Table, bool> tableFilter, bool usePascalCase, bool prependSchemaName, CommentsStyle includeComments, bool includeViews, CommentsStyle includeExtendedPropertyComments, Func<string, string, string> tableRename, Func<Column, Table, Column> updateColumn, bool usePrivateSetterForComputedColumns, bool includeSynonyms, bool dataAnnotations, bool dataAnnotationsSchema, bool isSqlCe);
1486-
public abstract List<StoredProcedure> ReadStoredProcs(Regex SchemaFilterExclude, Regex storedProcedureFilterExclude, bool usePascalCase, bool prependSchemaName , Func<string, string, string> StoredProcedureRename, bool includeTableValuedFunctions);
1486+
public abstract List<StoredProcedure> ReadStoredProcs(Regex SchemaFilterExclude, Regex storedProcedureFilterExclude, bool usePascalCase, bool prependSchemaName , Func<StoredProcedure, string> StoredProcedureRename, bool includeTableValuedFunctions);
14871487
public abstract List<ForeignKey> ReadForeignKeys(Func<string, string, string> tableRename, Func<ForeignKey, ForeignKey> foreignKeyFilter);
14881488
public abstract void ProcessForeignKeys(List<ForeignKey> fkList, Tables tables, bool usePascalCase, bool prependSchemaName, string collectionType, bool checkForFkNameClashes, CommentsStyle includeComments, Func<string, ForeignKey, string, short, string> ForeignKeyName, bool dataAnnotationsSchema);
14891489
public abstract void IdentifyForeignKeys(List<ForeignKey> fkList, Tables tables);
@@ -2398,7 +2398,7 @@ SELECT SERVERPROPERTY('Edition') AS Edition,
23982398
}
23992399
}
24002400

2401-
public override List<StoredProcedure> ReadStoredProcs(Regex schemaFilterExclude, Regex storedProcedureFilterExclude, bool usePascalCase, bool prependSchemaName , Func<string, string, string> StoredProcedureRename, bool includeTableValuedFunctions)
2401+
public override List<StoredProcedure> ReadStoredProcs(Regex schemaFilterExclude, Regex storedProcedureFilterExclude, bool usePascalCase, bool prependSchemaName , Func<StoredProcedure, string> StoredProcedureRename, bool includeTableValuedFunctions)
24022402
{
24032403
var result = new List<StoredProcedure>();
24042404
if(Cmd == null)
@@ -2447,7 +2447,7 @@ SELECT SERVERPROPERTY('Edition') AS Edition,
24472447
if((string.Compare(schema, "dbo", StringComparison.OrdinalIgnoreCase) != 0) && prependSchemaName)
24482448
sp.NameHumanCase = schema + "_" + sp.NameHumanCase;
24492449

2450-
sp.NameHumanCase = StoredProcedureRename(sp.NameHumanCase, schema);
2450+
sp.NameHumanCase = StoredProcedureRename(sp);
24512451
if(storedProcedureFilterExclude != null && (storedProcedureFilterExclude.IsMatch(sp.NameHumanCase) || storedProcedureFilterExclude.IsMatch(schema + "." + sp.NameHumanCase)))
24522452
continue;
24532453

0 commit comments

Comments
 (0)