<%--
Name:
Author:
Description:
--%>
<%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="False" Description="Template description here." %>
<%@ Property Name="tables" Type="SchemaExplorer.TableSchemaCollection" Default="" Optional="False" Category="??" Description="" OnChanged="" Editor="" EditorBase="" Serializer="" %>
<%@ Property Name="CreateZTable" Type="System.Boolean" Default="True" Optional="False" Category="Booleans" Description="This is a sample boolean property." %>
<%@ Property Name="CreateZTrigger" Type="System.Boolean" Default="True" Optional="False" Category="Booleans" Description="This is a sample boolean property." %>
<%@ Assembly Name="System.Data" %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="SchemaExplorer" %>
<%
foreach(SchemaExplorer.TableSchema table in tables)
{
String tableName = table.Name;
if (CreateZTable)
{
%>
--CreateZTable
drop table Z<%= tableName %>;
go
SELECT * into z<%= tableName %> FROM <%= tableName %> WHERE 1= 2;
go
ALTER TABLE Z<%= tableName %> ADD MYORDERNO VARCHAR(50) default newid() not null;
go
ALTER TABLE Z<%= tableName %> ADD MYOPERATEDATE DATETIME default getdate() not null;
go
<%
}
if (CreateZTrigger)
{
%>
--CreateZTrigger
SET ANSI_NULLS ON;
GO
SET QUOTED_IDENTIFIER ON;
GO
DROP TRIGGER [dbo].[DTT<%= tableName %>];
GO
create TRIGGER [dbo].[DTT<%= tableName %>] ON [DBO].[<%= tableName %>]
AFTER INSERT ,UPDATE
AS
set nocount on;
BEGIN
INSERT INTO Z<%= tableName %>
(
<%
int i = 0;
foreach(SchemaExplorer.ColumnSchema col in table.Columns)
{
if (i > 0)
{
%><%="," %><%=col.Name %><%
}
else
{
%><%=col.Name %><%
}
i++;
}
%>
)
select
<%
i = 0;
foreach(SchemaExplorer.ColumnSchema col in table.Columns)
{
if (i > 0)
{
%><%="," %><%=col.Name %><%
}
else
{
%><%=col.Name %><%
}
i++;
}
%>
from inserted;
END;
GO
<%
}
}
%>
<script runat="template">
// My methods here.
public string SampleMethod()
{
return "Method output.";
}
</script>