Various updates to MyGeneration
Moved ItemInsert code to ItemInsertExt.cs
This commit is contained in:
@@ -255,7 +255,9 @@ public class GeneratedTemplate : DotNetScriptTemplate
|
||||
{
|
||||
StartProc("purgeData");
|
||||
%>
|
||||
AS<%
|
||||
AS
|
||||
BEGIN TRY -- Try Block
|
||||
BEGIN TRANSACTION<%
|
||||
ArrayList toProcess = new ArrayList();
|
||||
ArrayList processed = new ArrayList();
|
||||
foreach(string sTable in _selectedTables)
|
||||
@@ -307,7 +309,7 @@ AS<%
|
||||
}
|
||||
if(processed.Count ==pCount)return;
|
||||
}
|
||||
EndProc("purgeData");
|
||||
EndProcTran("purgeData");
|
||||
}
|
||||
private void InitializeMembers()
|
||||
{
|
||||
@@ -387,6 +389,8 @@ AS
|
||||
<%=FormatColumns("{@} {dtype}{?null}",tbl.Columns,",\r\n","\t")%><%=FormatColumns("{@new} {dtype} output",Computed(tbl),"",",\r\n\t")%>
|
||||
)
|
||||
AS
|
||||
BEGIN TRY -- Try Block
|
||||
BEGIN TRANSACTION
|
||||
UPDATE [<%=tbl.Name%>]
|
||||
SET
|
||||
<%=FormatColumns("[{name}]={@}",Updatable(tbl),",\r\n","\t\t\t")%>
|
||||
@@ -405,7 +409,7 @@ AS
|
||||
FROM [<%=tbl.Name%>] WHERE <%=FormatColumns("[{name}]={@}",tbl.PrimaryKeys," AND ","")%>
|
||||
<%
|
||||
}
|
||||
EndProc(sproc);
|
||||
EndProcTran(sproc);
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Insert
|
||||
@@ -419,6 +423,8 @@ AS
|
||||
<%=FormatColumns("{@} {dtype}{?null}",Insertable(tbl),",\r\n","\t")%><%=FormatColumns("{@new} {dtype} output",NotInsertable(tbl),"",",\r\n\t")%>
|
||||
)
|
||||
AS
|
||||
BEGIN TRY -- Try Block
|
||||
BEGIN TRANSACTION
|
||||
INSERT INTO [<%=tbl.Name%>]
|
||||
(
|
||||
<%=FormatColumns("[{name}]",Insertable(tbl),",\r\n","\t\t")%>
|
||||
@@ -435,7 +441,7 @@ AS
|
||||
SELECT <%=FormatColumns("{@new}=[{name}]",cmp,"\r\n","\t\t")%>
|
||||
FROM [<%=tbl.Name%>] WHERE <%=FormatColumns("[{name}]={@key}",tbl.PrimaryKeys," AND ","")%><%
|
||||
}
|
||||
EndProc(sproc);
|
||||
EndProcTran(sproc);
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Delete
|
||||
@@ -448,7 +454,9 @@ AS
|
||||
(
|
||||
<%=FormatColumns("{@} {dtype}",tbl.PrimaryKeys,",\r\n","\t")%>
|
||||
)
|
||||
AS<%
|
||||
AS
|
||||
BEGIN TRY -- Try Block
|
||||
BEGIN TRANSACTION<%
|
||||
foreach(IForeignKey fk in tbl.ForeignKeys)
|
||||
{
|
||||
if(tbl != fk.ForeignTable)
|
||||
@@ -467,7 +475,7 @@ AS<%
|
||||
%>
|
||||
DELETE [<%=tbl.Name%>]
|
||||
WHERE <%=FormatColumns("[{name}] = {@}",tbl.PrimaryKeys," AND ","")%><%
|
||||
EndProc(sproc);
|
||||
EndProcTran(sproc);
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// SelectPK
|
||||
@@ -638,6 +646,24 @@ GO
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: <%=sproc%> Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: <%=sproc%> Error on Creation'
|
||||
GO
|
||||
<%
|
||||
SaveFile(sproc);
|
||||
}
|
||||
private void EndProcTran(string sproc)
|
||||
{
|
||||
%>
|
||||
IF( @@TRANCOUNT > 0 ) COMMIT
|
||||
END TRY
|
||||
BEGIN CATCH -- Catch Block
|
||||
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
|
||||
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
|
||||
EXEC vlnErrorHandler
|
||||
END CATCH
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: <%=sproc%> Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: <%=sproc%> Error on Creation'
|
||||
GO
|
||||
<%
|
||||
SaveFile(sproc);
|
||||
}
|
||||
|
Reference in New Issue
Block a user