Skip to content
Permalink
Browse files

Large pull request including 3 new features and three upgrades (#477)

* Formatting only

These changes are only formatting changes, no functionality changes.

Newlines, removing trailing spaces, and replacing tabs with spaces.

* VoidProcTransaction

Added feature allowing users to disable the default feature that wraps all custom sprocs that return void in a transaction.

By default this feature is left turned on.

One small piece of this feature ended up in the formatting commit in file ComponentDataAccess.cst lines 1527 and 1582, most of it is in this commit.

* ConnectionString in error

Add the connection string information without credentials to the custom error that gets thrown when a sql call blows up.

* Extended property feature

For the MS-SQL data access layer, add the ability to create custom Extended properties in the database on database columns (not tables).  There is a setting allowing the custom property prefix to be customized.  These custom properties are then written to each column enum value and can be used in code.

This provides a way to specify additional meta information in the database as the column level.

* Param sql string builder ' bug

Fixes a bug in the parameterized sql builder where tick marks get double encoded.  Also includes a couple other minor fixes to the sql string builder.

* New base classes

Until now, All table entities had a base class they inherrited from.
This changes gives all View entities their own base class, and Also creates a single overall base class for all netTiers table and view entities.

This allows methods to pass around objects at the view, table, or netTiers level.

* New Column attribute helper methods

New helper method used to get the custom attributes off of column enum entities.  Is an addition to the custom column attributes in sql feature.
  • Loading branch information...
jeremeguenther committed Sep 10, 2019
1 parent a517f1b commit 8557258d21c35864ed3af8bdc23952d0ca791eee

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -4,14 +4,14 @@
* Last modified at $Date: 2005/06/27 12:12:42 $
* $Revision: 1.31 $

Written By:
Ryan Hurdon
Description:
This script will create data access layer classes. It requires stored procedures
created from the procedure script. So for this code to work properly you need to run
the procedure template, the rowobject template, and the rowcollection template on
the same table. You can also optionally use the main script which will run them all
for you.
Written By:
Ryan Hurdon
Description:
This script will create data access layer classes. It requires stored procedures
created from the procedure script. So for this code to work properly you need to run
the procedure template, the rowobject template, and the rowcollection template on
the same table. You can also optionally use the main script which will run them all
for you.
--%>
<%@ CodeTemplate Src="..\TemplateLib\CommonSqlCode.cs" Inherits="MoM.Templates.CommonSqlCode" Language="C#" TargetLanguage="C#" Description="Component Object Class" ResponseEncoding="UTF-8" NoWarn="0108,0618,1572,1573,1574,0162,2002"%>
<%@ Assembly Name="SchemaExplorer" %>
@@ -33,80 +33,81 @@
<%@ Property Name="IncludeGetListByFK" Type="System.Boolean" Default="True" Category="Options" Description="If true get functions will be generated." %>
<%@ Property Name="IncludeGetListByIX" Type="System.Boolean" Default="True" Category="Options" Description="If true getlist functions will be generated." %>
<%@ Property Name="IncludeFind" Type="System.Boolean" Default="True" Category="Options" Description="If true find functions will be generated." %>
<%@ Property Name="VoidProcTransaction" Type="System.Boolean" Default="True" Category="Options" Description="If this is set to True, then automatically wrap all calls to stored procedures that have no return data in transactions; this way sprocs that only perform work will get all that work rolled back if they fail." %>

<%@ Property Name="ComponentPattern" Optional="False" Type="MoM.Templates.ComponentPatternType" Category="Pattern" Description="Component Pattern Type." %>
<%@ Property Name="CustomNonMatchingReturnType" Type="CustomNonMatchingReturnType" Default="DataSet" Category="Options" Description="When using custom stored procedures, if the returned rows do not match the fields in an entity, a DataSet or IDataReader will be returned. Choose One. This is useful if you've returned more than one resultset in a custom procedure; you can use a ConvertToDataSet(IDataReader) method in the Utility class to convert that to a DataSet." %>

<%@ Property Name="NameSpace" Optional="True" Type="System.String" Category="Style" Description="Object Namespace." %>
<%@ Property Name="BLLNameSpace" Optional="True" Type="System.String" Category="Style" Description="Component Namespace." %>
<%@ Property Name="DALNameSpace" Optional="True" Type="System.String" Category="Style" Description="DAL Namespace." %>

<%@ Property Name="UsePartialClass" Type="System.Boolean" Default="true" Category="General" Description="Indicates if partial class should be generated." %>
<%
string className = GetClassName(SourceTable);
string collectionClassName = GetClassName(SourceTable, ClassNameFormat.Collection);
string keyClassName = GetClassName(SourceTable, ClassNameFormat.Key);
string entitiesCollectionClassName = GetClassName(SourceTable, ClassNameFormat.Collection).Replace("<", "<Entities.");
string structName = GetClassName(SourceTable, ClassNameFormat.Struct);
string abstractClassName = GetClassName(SourceTable, ClassNameFormat.AbstractService);
string partialClassInternalPrefix = UsePartialClass ? "" : "";
string newCollectionClassName = "";
if (ComponentPattern == MoM.Templates.ComponentPatternType.DomainModel)
newCollectionClassName = string.Format("new {0} (", collectionClassName);

// Collection of all columns in the table.
ColumnSchemaCollection cols = SourceTable.Columns;
//Provides information about the indexes contained in the table.
//IndexSchemaCollection indexes = SourceTable.Indexes;
ColumnSchemaCollection colsUpdatable = new ColumnSchemaCollection();
foreach (ColumnSchema column in cols)
{
if ( ! IsIdentityColumn(column) && ! IsComputed(column) )
colsUpdatable.Add(column);
}
//Get the columns that are common to all tables
ColumnSchemaCollection commonColumns = GetCommonTableColumns(SourceTables);
string today = DateTime.Now.ToLongDateString();

// Collection of all columns in the table that are not primary keys.
//ColumnSchemaCollection nonKeys = SourceTable.NonPrimaryKeyColumns;
// Collection of all primary = SourceTable.PrimaryKey.key columns.
//ColumnSchemaCollection keysMemberColumns;
ColumnSchemaCollection keys = SourceTable.PrimaryKey.MemberColumns;
// Collection of ForeignKeys. Provides information about the foreign keys
//(keys where the current table is the foreign table) contained in the table.
TableKeySchemaCollection fkeys = SourceTable.ForeignKeys;
//Provides information about the primary keys
//(keys where the current table is the primary table) contained in the table.
TableKeySchemaCollection pkeys = SourceTable.PrimaryKeys;
//Provides information about the indexes contained in the table.
IndexSchemaCollection indexes = SourceTable.Indexes;
// this array store each Get BY MemberColumns in order to avoid to create doublon Get methods
System.Collections.ArrayList getbyKeys = new System.Collections.ArrayList();
string className = GetClassName(SourceTable);
string collectionClassName = GetClassName(SourceTable, ClassNameFormat.Collection);
string keyClassName = GetClassName(SourceTable, ClassNameFormat.Key);
string entitiesCollectionClassName = GetClassName(SourceTable, ClassNameFormat.Collection).Replace("<", "<Entities.");

string structName = GetClassName(SourceTable, ClassNameFormat.Struct);
string abstractClassName = GetClassName(SourceTable, ClassNameFormat.AbstractService);
string partialClassInternalPrefix = UsePartialClass ? "" : "";
string newCollectionClassName = "";

if (ComponentPattern == MoM.Templates.ComponentPatternType.DomainModel)
newCollectionClassName = string.Format("new {0} (", collectionClassName);

// Collection of all columns in the table.
ColumnSchemaCollection cols = SourceTable.Columns;

//Provides information about the indexes contained in the table.
//IndexSchemaCollection indexes = SourceTable.Indexes;

ColumnSchemaCollection colsUpdatable = new ColumnSchemaCollection();
foreach (ColumnSchema column in cols)
{
if ( ! IsIdentityColumn(column) && ! IsComputed(column) )
colsUpdatable.Add(column);
}

//Get the columns that are common to all tables
ColumnSchemaCollection commonColumns = GetCommonTableColumns(SourceTables);

string today = DateTime.Now.ToLongDateString();

// Collection of all columns in the table that are not primary keys.
//ColumnSchemaCollection nonKeys = SourceTable.NonPrimaryKeyColumns;

// Collection of all primary = SourceTable.PrimaryKey.key columns.
//ColumnSchemaCollection keysMemberColumns;
ColumnSchemaCollection keys = SourceTable.PrimaryKey.MemberColumns;

// Collection of ForeignKeys. Provides information about the foreign keys
//(keys where the current table is the foreign table) contained in the table.
TableKeySchemaCollection fkeys = SourceTable.ForeignKeys;

//Provides information about the primary keys
//(keys where the current table is the primary table) contained in the table.
TableKeySchemaCollection pkeys = SourceTable.PrimaryKeys;

//Provides information about the indexes contained in the table.
IndexSchemaCollection indexes = SourceTable.Indexes;

// this array store each Get BY MemberColumns in order to avoid to create doublon Get methods
System.Collections.ArrayList getbyKeys = new System.Collections.ArrayList();
%>

/*
File generated by NetTiers templates [www.nettiers.net]
<%
if( IncludeGeneratedDate)
{
%>
Generated on : <%=DateTime.Now.ToLongDateString()%>
<%
}
%>
Important: Do not modify this file. Edit the file <%=className%>.cs instead.
File generated by NetTiers templates [www.nettiers.net]
<%
if( IncludeGeneratedDate)
{
%>
Generated on : <%=DateTime.Now.ToLongDateString()%>
<%
}
%>
Important: Do not modify this file. Edit the file <%=className%>.cs instead.
*/

#region Using Directives
@@ -132,56 +133,56 @@ using Microsoft.Practices.EnterpriseLibrary.Logging;
#endregion

namespace <%=NameSpace%>
{
///<summary>
/// An object representation of the '<%=SourceTable.Name%>' table.
///</summary>
/// <remarks>
/// IMPORTANT!!! You should not modify this <% if (UsePartialClass) Response.Write("partial "); else Response.Write("base "); %> class, modify the <%= className%>.cs file instead.
/// All custom implementations should be done in the <see cref="<%=className%>"/> class.
/// </remarks>
[DataObject]
[CLSCompliant(true)]
public <% if (UsePartialClass) Response.Write("partial "); %>class <%=abstractClassName%> : ServiceBase<<%= className %>, <%= keyClassName %>>
{

#region Constructors
///<summary>
/// Creates a new <see cref="<%=className%>"/> instance .
///</summary>
public <%=abstractClassName%>() : base()
{
}
///<summary>
/// A simple factory method to create a new <see cref="<%=className%>"/> instance.
///</summary>
<% for (int x=0; x < colsUpdatable.Count; x++) { %>
///<param name="<%=GetFieldName(colsUpdatable[x]) %>"><%= GetColumnXmlComment(colsUpdatable[x],2)%></param>
<% } %>
public static <%=className%> Create<%=className%>(<% for (int x=0; x < colsUpdatable.Count; x++) { %><%= GetCSType(colsUpdatable[x]) %> <%= GetFieldName(colsUpdatable[x]) %><%if (x < colsUpdatable.Count -1){%>, <%} }// end for %>)
{
<%=className%> newEntity<%=className%> = new <%=className%>();
<% for (int x=0; x < colsUpdatable.Count; x++) { %>
<%= GetObjectPropertyAccessor(colsUpdatable[x], "newEntity" + className) %> = <%= GetFieldName(colsUpdatable[x]) %>;
<% }// end for %>
return newEntity<%=className%>;
}
#endregion Constructors
<%
// If the chosen pattern to implement is a domain pattern, go ahead
// and fill all data repository wrapper access here.
CodeTemplate template = CodeTemplates["ComponentDataAccess.cst"];
this.CopyPropertiesTo(template);
template.SetProperty("RenderOverload", false);
template.SetProperty("RenderImplementation", true);
template.SetProperty("ComponentPattern", ComponentPattern);
Response.Write(template.RenderToString()); %>
}//End Class
{

///<summary>
/// An object representation of the '<%=SourceTable.Name%>' table.
///</summary>
/// <remarks>
/// IMPORTANT!!! You should not modify this <% if (UsePartialClass) Response.Write("partial "); else Response.Write("base "); %> class, modify the <%= className%>.cs file instead.
/// All custom implementations should be done in the <see cref="<%=className%>"/> class.
/// </remarks>
[DataObject]
[CLSCompliant(true)]
public <% if (UsePartialClass) Response.Write("partial "); %>class <%=abstractClassName%> : ServiceBase<<%= className %>, <%= keyClassName %>>
{

#region Constructors
///<summary>
/// Creates a new <see cref="<%=className%>"/> instance .
///</summary>
public <%=abstractClassName%>() : base()
{
}

///<summary>
/// A simple factory method to create a new <see cref="<%=className%>"/> instance.
///</summary>
<% for (int x=0; x < colsUpdatable.Count; x++) { %>
///<param name="<%=GetFieldName(colsUpdatable[x]) %>"><%= GetColumnXmlComment(colsUpdatable[x],2)%></param>
<% } %>
public static <%=className%> Create<%=className%>(<% for (int x=0; x < colsUpdatable.Count; x++) { %><%= GetCSType(colsUpdatable[x]) %> <%= GetFieldName(colsUpdatable[x]) %><%if (x < colsUpdatable.Count -1){%>, <%} }// end for %>)
{
<%=className%> newEntity<%=className%> = new <%=className%>();
<% for (int x=0; x < colsUpdatable.Count; x++) { %>
<%= GetObjectPropertyAccessor(colsUpdatable[x], "newEntity" + className) %> = <%= GetFieldName(colsUpdatable[x]) %>;
<% }// end for %>
return newEntity<%=className%>;
}
#endregion Constructors
<%
// If the chosen pattern to implement is a domain pattern, go ahead
// and fill all data repository wrapper access here.

CodeTemplate template = CodeTemplates["ComponentDataAccess.cst"];

this.CopyPropertiesTo(template);
template.SetProperty("RenderOverload", false);
template.SetProperty("RenderImplementation", true);
template.SetProperty("ComponentPattern", ComponentPattern);
Response.Write(template.RenderToString()); %>

}//End Class
} // end namespace


0 comments on commit 8557258

Please sign in to comment.
You can’t perform that action at this time.