diff --git a/PROMS/MyGeneration/csla_21/CSLA_Objects.csgen b/PROMS/MyGeneration/csla_21/CSLA_Objects.csgen
index 04f43b20..7e7d85fa 100644
--- a/PROMS/MyGeneration/csla_21/CSLA_Objects.csgen
+++ b/PROMS/MyGeneration/csla_21/CSLA_Objects.csgen
@@ -50,7 +50,7 @@ public class GeneratedGui : DotNetScriptGui
// Namespace
GuiLabel label2 = ui.AddLabel( "label2", "Namespace: ", "Provide your objects namespace." );
label2.Width = 280;
- GuiTextBox classNamespace = ui.AddTextBox( "classNamespace", "Volian.CSLA.Library", "Provide your objects namespace." );
+ GuiTextBox classNamespace = ui.AddTextBox( "classNamespace", "VEPROMS.CSLA.Library", "Provide your objects namespace." );
classNamespace.Width = 280;
GuiLabel label3 = ui.AddLabel( "label3", "Member prefix: ", "Provide your Prefix." );
@@ -238,7 +238,7 @@ public class GeneratedTemplate : DotNetScriptTemplate
public bool AddToClassList(string className)
{
- if(_classList.Contains(className))
+ if (_classList.Contains(className))
{
_duplicateList.Add(className);
return false;
@@ -252,17 +252,17 @@ public class GeneratedTemplate : DotNetScriptTemplate
public delegate bool Filter(IColumn column);
public string Debug(string str)
{
- if(_chkDebug && str.CompareTo(_tbDebug) >= 0)return "/**** MyGeneration Debug " + str + " ****/";
+ if (_chkDebug && str.CompareTo(_tbDebug) >= 0)return "/**** MyGeneration Debug " + str + " ****/";
return "";
}
public string DebugLine(string str)
{
- if(_chkDebug && str.CompareTo(_tbDebug) >= 0)return "\r\n/**** MyGeneration Debug " + str + " ****/";
+ if (_chkDebug && str.CompareTo(_tbDebug) >= 0)return "\r\n/**** MyGeneration Debug " + str + " ****/";
return "";
}
public void SaveFile()
{
- if(_chkCreateFiles)
+ if (_chkCreateFiles)
{
output.save( Path.Combine( _exportPath, _className + ".cs" ), false );
output.clear();
@@ -271,8 +271,9 @@ public class GeneratedTemplate : DotNetScriptTemplate
public GeneratedTemplate( ZeusContext context ) : base( context ) {}
public override void Render()
- {
- if(context.Objects.ContainsKey("DnpUtils"))DnpUtils.SaveInputToCache(context);
+ {
+ DateTime tStart = DateTime.Now;
+ if (context.Objects.ContainsKey("DnpUtils"))DnpUtils.SaveInputToCache(context);
try{
InitializeDictionaries();
_dbName = input["chooseDatabase"].ToString();
@@ -299,13 +300,13 @@ public class GeneratedTemplate : DotNetScriptTemplate
_chkPartEXT=(bool)input["chkPartEXT"];
_chkPartCM=(bool)input["chkPartCM"];
_chkPartL4N=(bool)input["chkPartL4N"];
- if(_chkPartL4N)
+ if (_chkPartL4N)
{
- _databaseLogDebug = "if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat";
- _databaseLogInfo = "if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat";
- _databaseLogWarn = "if(_MyLog.IsWarnEnabled)_MyLog.WarnFormat";
- _databaseLogError = "if(_MyLog.IsErrorEnabled)_MyLog.Error";
- _databaseLogFatal = "if(_MyLog.IsFatalEnabled)_MyLog.Fatal";
+ _databaseLogDebug = "if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat";
+ _databaseLogInfo = "if (_MyLog.IsInfoEnabled) _MyLog.InfoFormat";
+ _databaseLogWarn = "if (_MyLog.IsWarnEnabled) _MyLog.WarnFormat";
+ _databaseLogError = "if (_MyLog.IsErrorEnabled) _MyLog.Error";
+ _databaseLogFatal = "if (_MyLog.IsFatalEnabled) _MyLog.Fatal";
}
else
{
@@ -321,7 +322,7 @@ public class GeneratedTemplate : DotNetScriptTemplate
_tbDebug=(string)input["tbDebug"];
_classList=new ArrayList();
_duplicateList=new ArrayList();
- if(_chkDatabase)GenerateDatabase();
+ if (_chkDatabase)GenerateDatabase();
foreach( string _newTable in _selectedTables )
{
_workingTable = MyMeta.Databases[_dbName].Tables[_newTable];
@@ -329,7 +330,7 @@ public class GeneratedTemplate : DotNetScriptTemplate
}
GeneratePropertyDescriptor();
GenerateCommonRules();
- if(_duplicateList.Count > 0)
+ if (_duplicateList.Count > 0)
{
WriteLine("Duplicate Classes");
foreach(string s in _duplicateList)
@@ -337,6 +338,8 @@ public class GeneratedTemplate : DotNetScriptTemplate
WriteLine("[{0}]",s);
}
}
+ DateTime tEnd = DateTime.Now;
+ WriteLine(string.Format("Total Generation Time: {0} Seconds",TimeSpan.FromTicks(tEnd.Ticks - tStart.Ticks).TotalSeconds));
//foreach( string _newView in _selectedViews )
//{
// IView _workingView = MyMeta.Databases[_dbName].Views[_newView];
@@ -357,6 +360,7 @@ public class GeneratedTemplate : DotNetScriptTemplate
dicRead["DateTime"]="{fmember} = dr.GetDateTime(\"{fname}\");";
dicRead["timestamp"]="dr.GetBytes(\"{fname}\", 0, {fmember}, 0, 8);";
dicRead["image"]="{fmember} = (byte[])dr.GetValue(\"{fname}\");";
+ dicRead["varbinary"]="{fmember} = (byte[])dr.GetValue(\"{fname}\");";
dicRead["int"]="{fmember} = dr.GetInt32(\"{fname}\");";
dicRead["Int32"]="{fmember} = dr.GetInt32(\"{fname}\");";
dicRead["Int16"]="{fmember} = dr.GetInt16(\"{fname}\");";
@@ -381,27 +385,27 @@ public class GeneratedTemplate : DotNetScriptTemplate
dicRead["decimal?"]="{fmember} = ({ctype})dr.GetValue(\"{fname}\");";
dicRead["bool?"]="{fmember} = ({ctype})dr.GetValue(\"{fname}\");";
dicRead["long?"]="{fmember} = ({ctype})dr.GetValue(\"{fname}\");";
- dicRead["DateTime?"]="if(!dr.IsDBNull(dr.GetOrdinal(\"{fname}\"))) {fmember} = dr.GetDateTime(\"{fname}\");";
+ dicRead["DateTime?"]="if (!dr.IsDBNull(dr.GetOrdinal(\"{fname}\"))) {fmember} = dr.GetDateTime(\"{fname}\");";
}
private void GenerateClassFiles(ITable tbl)
{
- if(_chkGenerateMain)GenerateMainClass(tbl);
+ if (_chkGenerateMain)GenerateMainClass(tbl);
Hashtable dicAlias = new Hashtable();
foreach(IForeignKey fk in tbl.ForeignKeys)
{
- if(tbl == fk.PrimaryTable)
+ if (tbl == fk.PrimaryTable)
{
- if(!IsPrimaryKey(fk))
+ if (!IsPrimaryKey(fk))
{
//string sAlias = GetAlias(dicAlias,fk.ForeignTable);
string sAlias = GetAlias(fk);
- if(_chkFKList)GenerateFKListClass(fk,sAlias);
- if(_chkFKItem && fk.PrimaryTable != fk.ForeignTable )GenerateFKClass(fk,sAlias);
+ if (_chkFKList)GenerateFKListClass(fk,sAlias);
+ if (_chkFKItem && fk.PrimaryTable != fk.ForeignTable )GenerateFKClass(fk,sAlias);
}
}
}
- if(_chkInfoList && AnyNotOneToOne(tbl))GenerateInfoListClass(tbl); // InfoList if any non 1 to 1 relationships
- if(_chkInfo)GenerateInfoClass(tbl);
+ if (_chkInfoList && AnyNotOneToOne(tbl))GenerateInfoListClass(tbl); // InfoList if any non 1 to 1 relationships
+ if (_chkInfo)GenerateInfoClass(tbl);
}
// private void ShowForeignKey(ForeignKey fk)
// {
@@ -414,11 +418,11 @@ public class GeneratedTemplate : DotNetScriptTemplate
{
_className = ClassName( tbl );
_PropDescList.Add(_className);
- if(!AddToClassList(_className))return;
+ if (!AddToClassList(_className))return;
_tableName = tbl.Alias;
vlnHeader("\r\nusing System.Collections.Generic;\r\nusing Csla.Validation;");
string sInterface="";
- if(_chkPartCM)
+ if (_chkPartCM)
{
//sInterface = ", ICustomTypeDescriptor";
%>
@@ -430,30 +434,30 @@ public class GeneratedTemplate : DotNetScriptTemplate
Log4Net();
vlnRefreshInfo();
vlnCollection(tbl,UniqueIndexes(tbl),false);
- if(_chkPartBM)vlnBusinessMethods(tbl.Columns);
- if(_chkPartVR)vlnValidationRules(tbl.Columns);
- if(_chkPartAR)vlnAuthorizationRules(tbl.Columns);
- if(_chkPartFM)vlnFactoryMethods(tbl.Columns);
- if(_chkPartDA)vlnDataAccessPortal(tbl.Columns);
- if(_chkPartEX)vlnExists(tbl.Columns);
- if(_chkPartDF)vlnDefaults(tbl.Columns);
+ if (_chkPartBM)vlnBusinessMethods(tbl.Columns);
+ if (_chkPartVR)vlnValidationRules(tbl.Columns);
+ if (_chkPartAR)vlnAuthorizationRules(tbl.Columns);
+ if (_chkPartFM)vlnFactoryMethods(tbl.Columns);
+ if (_chkPartDA)vlnDataAccessPortal(tbl.Columns);
+ if (_chkPartEX)vlnExists(tbl.Columns);
+ if (_chkPartDF)vlnDefaults(tbl.Columns);
vlnFooterCM("");
- if(_chkPartEXT)vlnExtension(tbl.Columns);
+ if (_chkPartEXT)vlnExtension(tbl.Columns);
SaveFile();
}
private void GenerateFKListClass(IForeignKey fk,string sAlias)
{
_className = ClassName( fk.PrimaryTable ) + ClassesName( fk.ForeignTable )+sAlias;
_className = FKClassesName(fk)+sAlias;
- if(!AddToClassList(_className))return;
- if(fk.PrimaryTable == fk.ForeignTable)
+ if (!AddToClassList(_className))return;
+ if (fk.PrimaryTable == fk.ForeignTable)
_subclassName = ClassName( fk.PrimaryTable);
else
_subclassName = ClassName( fk.PrimaryTable) + ClassName( fk.ForeignTable )+sAlias;
_tableName = "//TODO: No Table Name";
- vlnHeader("\r\nusing Csla.Validation;");
+ vlnHeader("\r\nusing System.Collections.Generic;\r\nusing Csla.Validation;");
string sInterface = "";
- if(_chkPartCM)
+ if (_chkPartCM)
{
sInterface = ", ICustomTypeDescriptor";
%>
@@ -463,10 +467,10 @@ public class GeneratedTemplate : DotNetScriptTemplate
public partial class <%=_className%> : BusinessListBase<<%=_className%>, <%=_subclassName%>><%=sInterface%>, IVEHasBrokenRules
{<%
Log4Net();
- if(_chkPartBM)vlnBusinessMethodsFKList(fk,sAlias);
- if(_chkPartVR)vlnValidationRulesFKList(fk,sAlias);
- if(_chkPartFM)vlnFactoryMethodsFKList(fk,sAlias);
- if(_chkPartDA)vlnDataAccessPortalFKList(fk,sAlias);
+ if (_chkPartBM)vlnBusinessMethodsFKList(fk,sAlias);
+ if (_chkPartVR)vlnValidationRulesFKList(fk,sAlias);
+ if (_chkPartFM)vlnFactoryMethodsFKList(fk,sAlias);
+ if (_chkPartDA)vlnDataAccessPortalFKList(fk,sAlias);
vlnFooterCM(ClassesName( fk.ForeignTable ) + sAlias);
SaveFile();
}
@@ -474,11 +478,11 @@ public class GeneratedTemplate : DotNetScriptTemplate
{
_className = ClassName( fk.PrimaryTable ) + ClassName( fk.ForeignTable ) + sAlias;
_PropDescList.Add(_className);
- if(!AddToClassList(_className))return;
+ if (!AddToClassList(_className))return;
_tableName = fk.ForeignTable.Alias;
- vlnHeader("\r\nusing Csla.Validation;");
+ vlnHeader("\r\nusing System.Collections.Generic;\r\nusing Csla.Validation;");
string sInterface="";
- if(_chkPartCM)
+ if (_chkPartCM)
{
//sInterface = ", ICustomTypeDescriptor";
%>
@@ -488,25 +492,25 @@ public class GeneratedTemplate : DotNetScriptTemplate
public partial class <%=_className%> : BusinessBase<<%=_className%>><%=sInterface%>, IVEHasBrokenRules
{<%
Log4Net();
- if(_chkPartBM)vlnBusinessMethodsFKItem(fk,sAlias);
- if(_chkPartVR)vlnValidationRulesFKItem(fk,sAlias);
- if(_chkPartAR)vlnAuthorizationRulesFKItem(fk,sAlias);
- if(_chkPartFM)vlnFactoryMethodsFKItem(fk,sAlias);
- if(_chkPartDA)vlnDataAccessPortalFKItem(fk,sAlias);
- if(_chkPartDF)vlnDefaults(fk.ForeignTable.Columns);
+ if (_chkPartBM)vlnBusinessMethodsFKItem(fk,sAlias);
+ if (_chkPartVR)vlnValidationRulesFKItem(fk,sAlias);
+ if (_chkPartAR)vlnAuthorizationRulesFKItem(fk,sAlias);
+ if (_chkPartFM)vlnFactoryMethodsFKItem(fk,sAlias);
+ if (_chkPartDA)vlnDataAccessPortalFKItem(fk,sAlias);
+ if (_chkPartDF)vlnDefaults(fk.ForeignTable.Columns);
vlnFooterCM("");
- if(_chkPartEXT)vlnExtension(fk.ForeignTable.Columns);
+ if (_chkPartEXT)vlnExtension(fk.ForeignTable.Columns);
SaveFile();
}
private void vlnFooterCM(string displayName)
{
- if(_chkPartCM)
+ if (_chkPartCM)
{
- if(displayName!="")vlnComponentModelFKList();
+ if (displayName!="")vlnComponentModelFKList();
%>
} // Class<%
- if(displayName!="")vlnPropertyDescriptorFKList();
- if(displayName!="")vlnConvertorFKList(displayName);
+ if (displayName!="")vlnPropertyDescriptorFKList();
+ if (displayName!="")vlnConvertorFKList(displayName);
else vlnConvertorFKItem();
%>
} // Namespace
@@ -523,12 +527,12 @@ public class GeneratedTemplate : DotNetScriptTemplate
private void GenerateInfoListClass( ITable tbl )
{
_className = ClassName( tbl ) + "InfoList";
- if(!AddToClassList(_className))return;
+ if (!AddToClassList(_className))return;
_tableName = tbl.Alias;
_subclassName = ClassName( tbl ) + "Info";
vlnHeader("\r\nusing System.Collections.Generic;");
string sInterface="";
- if(_chkPartCM)
+ if (_chkPartCM)
{
sInterface = ", ICustomTypeDescriptor";
%>
@@ -538,7 +542,7 @@ public class GeneratedTemplate : DotNetScriptTemplate
public partial class <%=_className%> : ReadOnlyListBase<<%=_className%>, <%=_subclassName%>><%=sInterface%>, IDisposable
{<%
Log4Net();
- if(_chkPartBM)
+ if (_chkPartBM)
{
%>
#region Business Methods
@@ -567,8 +571,8 @@ public class GeneratedTemplate : DotNetScriptTemplate
}
}
#endregion<%}
- if(_chkPartFM)vlnFactoryMethodsInfoList(tbl.Columns);
- if(_chkPartDA)vlnDataAccessPortalInfoList(tbl.Columns);
+ if (_chkPartFM)vlnFactoryMethodsInfoList(tbl.Columns);
+ if (_chkPartDA)vlnDataAccessPortalInfoList(tbl.Columns);
vlnFooterCM(ClassesName( tbl ) );
SaveFile();
}
@@ -576,11 +580,11 @@ public class GeneratedTemplate : DotNetScriptTemplate
{
_className = ClassName( tbl ) + "Info";
_PropDescList.Add(_className);
- if(!AddToClassList(_className))return;
+ if (!AddToClassList(_className))return;
_tableName = tbl.Alias;
vlnHeader("\r\nusing System.Collections.Generic;","\r\n\tpublic delegate void " + _className + "Event(object sender);");
string sInterface="";
- if(_chkPartCM)
+ if (_chkPartCM)
{
//sInterface = ", ICustomTypeDescriptor";
%>
@@ -596,9 +600,9 @@ public class GeneratedTemplate : DotNetScriptTemplate
}<%
Log4Net();
vlnCollection(tbl,new ArrayList(),true);
- if(_chkPartBM)vlnBusinessMethodsInfo(tbl.Columns);
- if(_chkPartFM)vlnFactoryMethodsInfo(tbl.Columns);
- if(_chkPartDA)vlnDataAccessPortalInfo(tbl.Columns);
+ if (_chkPartBM)vlnBusinessMethodsInfo(tbl.Columns);
+ if (_chkPartFM)vlnFactoryMethodsInfo(tbl.Columns);
+ if (_chkPartDA)vlnDataAccessPortalInfo(tbl.Columns);
vlnInfoExtension(tbl.Columns);//20070410
vlnFooterCM("");
SaveFile();
@@ -621,7 +625,7 @@ public class GeneratedTemplate : DotNetScriptTemplate
}
private void vlnHeader(string sUsing,string sDelegate,bool serialize)
{
- if(_chkVolian){
+ if (_chkVolian){
%>// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
@@ -641,7 +645,7 @@ using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;<%
- if(_chkPartCM)
+ if (_chkPartCM)
{
%>
using System.ComponentModel;<%
@@ -652,7 +656,7 @@ namespace <%=_nameSpace%>
///
/// <%=_className%> Generated by MyGeneration using the CSLA Object Mapping template
/// <%
- if(serialize)
+ if (serialize)
{
%>
[Serializable()]<%
@@ -662,10 +666,10 @@ namespace <%=_nameSpace%>
{
IColumns colsi = ind.Columns;
IColumns colsp = ind.Table.PrimaryKeys;
- if(colsi.Count != colsp.Count)return false;
+ if (colsi.Count != colsp.Count)return false;
for(int i=0;i
ArrayList retval = new ArrayList();
foreach(Index ind in tbl.Indexes)
{
- if(!IsPrimaryKey(ind) && ind.Unique)
+ if (!IsPrimaryKey(ind) && ind.Unique)
{
retval.Add(ind);
}
@@ -690,49 +694,69 @@ namespace <%=_nameSpace%>
string pKeysType = FormatColumns("{ctype} {local}",tbl.PrimaryKeys,", ","");
%>
#region Collection
- protected static List<<%=_className%>> _AllList = new List<<%=_className%>>();
- private static Dictionary> _AllByPrimaryKey = new Dictionary>();<%
+ private static List<<%=_className%>> _CacheList = new List<<%=_className%>>();
+ protected static void AddToCache(<%=_className%> <%=LocalName(_className)%>)
+ {
+ if (!_CacheList.Contains(<%=LocalName(_className)%>)) _CacheList.Add(<%=LocalName(_className)%>); // In AddToCache
+ }
+ protected static void RemoveFromCache(<%=_className%> <%=LocalName(_className)%>)
+ {
+ while (_CacheList.Contains(<%=LocalName(_className)%>)) _CacheList.Remove(<%=LocalName(_className)%>); // In RemoveFromCache
+ }
+ private static Dictionary>> _CacheByPrimaryKey = new Dictionary>>();<%
//ArrayList uniqueIndexes=UniqueIndexes(tbl);
foreach(IIndex ind in uniqueIndexes)
{
string sBy = FormatColumns("{name}",ind.Columns,"_","");
%>
- private static Dictionary> _AllBy<%=sBy%> = new Dictionary>();<%
+ private static Dictionary>> _CacheBy<%=sBy%> = new Dictionary>>();<%
}
%>
private static void ConvertListToDictionary()
{
List<<%=_className%>> remove = new List<<%=_className%>>();
- foreach (<%=_className%> tmp in _AllList)
+ foreach (<%=_className%> tmp in _CacheList)
{
- _AllByPrimaryKey[<%=pKey%>]=tmp; // Primary Key<%
+ if (!_CacheByPrimaryKey.ContainsKey(<%=pKey%>))
+ {
+ _CacheByPrimaryKey[<%=pKey%>] = new List<<%=_className%>>(); // Add new list for PrimaryKey<%
foreach(IIndex ind in uniqueIndexes)
{
string sBy = FormatColumns("{name}",ind.Columns,"_","");
string sKey = FormatColumns("tmp.{prop}.ToString()",ind.Columns," + \"_\" + ","");
%>
- _AllBy<%=sBy%>[<%=sKey%>] = tmp; // Unique Index<%
+ _CacheBy<%=sBy%>[<%=sKey%>] = new List<<%=_className%>>(); // Add new list for <%=sBy%><%
+ }
+%>
+ }
+ _CacheByPrimaryKey[<%=pKey%>].Add(tmp); // Add to Primary Key list<%
+ foreach(IIndex ind in uniqueIndexes)
+ {
+ string sBy = FormatColumns("{name}",ind.Columns,"_","");
+ string sKey = FormatColumns("tmp.{prop}.ToString()",ind.Columns," + \"_\" + ","");
+%>
+ _CacheBy<%=sBy%>[<%=sKey%>].Add(tmp); // Unique Index<%
}
%>
remove.Add(tmp);
}
foreach (<%=_className%> tmp in remove)
- _AllList.Remove(tmp);
+ RemoveFromCache(tmp);
}<%
- if(bInfo && AnyNotOneToOne(_workingTable)) // AddList function for infolist - Any non 1 to 1 relationships
+ if (bInfo && AnyNotOneToOne(_workingTable)) // AddList function for infolist - Any non 1 to 1 relationships
{
%>
internal static void AddList(<%=_className%>List lst)
{
- foreach (<%=_className%> item in lst) _AllList.Add(item);
+ foreach (<%=_className%> item in lst) AddToCache(item);
}<%
}
%>
- public static <%=_className%> GetExistingByPrimaryKey(<%=pKeysType%>)
+ protected static <%=_className%> GetCachedByPrimaryKey(<%=pKeysType%>)
{
ConvertListToDictionary();
string key = <%=pKey2%>;
- if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
+ if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}<%
foreach(IIndex ind in uniqueIndexes)
@@ -742,11 +766,11 @@ namespace <%=_nameSpace%>
string sKeysType = FormatColumns("{ctype} {local}",ind.Columns,", ","");
string sKeys = FormatColumns("{local}",ind.Columns,", ","");
%>
- public static <%=_className%> GetExistingBy<%=sBy%>(<%=sKeysType%>)
+ protected static <%=_className%> GetCachedBy<%=sBy%>(<%=sKeysType%>)
{
ConvertListToDictionary();
string key = <%=sKey%>;
- if (_AllBy<%=sBy%>.ContainsKey(key)) return _AllBy<%=sBy%>[key];
+ if (_CacheBy<%=sBy%>.ContainsKey(key)) return _CacheBy<%=sBy%>[key][0];
return null;
}<%
}
@@ -772,9 +796,9 @@ namespace <%=_nameSpace%>
private string ParentCheck(IColumn col) // 20070221 - Logic to check for parent value
{
IForeignKey pfk = FKParentFK(col.Table);
- if(pfk == null)return null;
+ if (pfk == null)return null;
IColumn relCol = RelatedColumnF(col,pfk);
- if(relCol==null) return null;
+ if (relCol==null) return null;
return FormatColumn("\r\n\t\t\t\tif (_" + ParentName(pfk) + " != null) return _" + ParentName(pfk) + ".{prop};",relCol);
}
private void vlnProperties(IColumns Columns)
@@ -786,24 +810,24 @@ namespace <%=_nameSpace%>
// bool bRelatedObject = true;
vlnIdentity(col);
// string sParentCheck = ParentCheck(col);
-// if(sParentCheck != null)
+// if (sParentCheck != null)
// {
// bReadOnly=true;
// bRelatedObject=false;
// }
// Need logic to handle parent child
string sParentCheck="";
- if(IsRelObj(col))
+ if (IsRelObj(col))
sParentCheck =FormatColumn("\r\n\t\t\t\tif ({!member} != null) {member} = {!member}.{!column};",col);
vlnProperty(CSLAType( col ),MemberName(col)
- ,PropertyName(col),InitializeValue( col ),GetDescription(col),bReadOnly || IsRelObj(col),col.IsInPrimaryKey,false,null,sParentCheck,null);
-// if(bRelatedObject)
+ ,PropertyName(col),InitializeValue( col ),GetDescription(col),bReadOnly || IsRelObj(col),col.IsInPrimaryKey,false,null,sParentCheck,null,null);
+// if (bRelatedObject)
vlnRelObjProperty(col,bReadOnly,false);
}
// Add Foreign Key Properties - This should be controllable
// foreach(IColumn field in Columns)
// {
-// if( field.IsInForeignKey && field.IsInPrimaryKey)
+// if (field.IsInForeignKey && field.IsInPrimaryKey)
// {
//A column that's in a fk and in the pk represents a fk relationship
//from another table, a one-to-many relationship. (This might be
@@ -815,73 +839,123 @@ namespace <%=_nameSpace%>
Hashtable dicAlias = new Hashtable();
foreach(IForeignKey fk in _workingTable.ForeignKeys)
{
- if(fk.PrimaryTable == _workingTable){
+ if (fk.PrimaryTable == _workingTable){
//string sAlias = GetAlias(dicAlias,fk.ForeignTable);
string sAlias = GetAlias(fk);
// string sList = _className + ClassesName( fk.ForeignTable );
string sList = FKClassName(fk );
string sLists = FKClassesName(fk );
vlnProperty("int",MemberName(sList) + sAlias + "Count" ,sList + sAlias + "Count", " = 0;",
- "Count of " + sLists + " for this " + ClassName(_workingTable) + Debug("20070501.3"),true,false,false,null,null,null);
- if(!IsPrimaryKey(fk)){
+ "Count of " + sLists + " for this " + ClassName(_workingTable) + Debug("20070501.3"),true,false,false,null,null,null,null);
+ if (!IsPrimaryKey(fk)){
//vlnProperty(sLists+sAlias,MemberName(sLists)+sAlias,sLists + sAlias,
- //" = " + sLists+sAlias + ".New();","Related Field" + Debug("20070501.2"),true,false,true,fk,null,null);
+ //" = " + sLists+sAlias + ".New();","Related Field" + Debug("20070501.2"),true,false,true,fk,null,null,null);
vlnProperty(sLists+sAlias,MemberName(sLists)+sAlias,sLists + sAlias,
- " = null;","Related Field" + Debug("20070501.2"),true,false,true,fk,null,null);
+ " = null;","Related Field" + Debug("20070501.2"),true,false,true,fk,null,null,null);
//sExtDirty += " || " + MemberName(sLists+sAlias) + ".IsDirty";
//sExtValid += " && " + MemberName(sLists+sAlias) + ".IsValid";
- sExtDirty += string.Format(" || ({0} == null? false : {0}.IsDirty)",MemberName(sLists+sAlias));
- sExtValid += string.Format(" && ({0} == null? true : {0}.IsValid)",MemberName(sLists+sAlias));
+ sExtDirty += string.Format(" || ({0} == null ? false : {0}.IsDirtyList(list))",MemberName(sLists+sAlias));
+ sExtValid += string.Format(" && ({0} == null ? true : {0}.IsValid)",MemberName(sLists+sAlias));
} else {
string sItem = ClassName(fk.ForeignTable);
//vlnProperty(sItem+sAlias, MemberName("My" + sItem)+sAlias,"My" + sItem + sAlias,
- //" = My" + sItem+sAlias + ".New();","Related Field",true,false,true,fk,null);
- string sCheck = string.Format("\r\n\t\t\t\tif ( {0} == null) {0} = {1}.New({2});",
+ //" = My" + sItem+sAlias + ".New();","Related Field",true,false,true,fk,null,null);
+ string sCheck = string.Format("\r\n\t\t\t\tif ({0} == null) {0} = {1}.New({2});",
MemberName("My" + sItem)+sAlias, sItem, OneToOne(fk) ? "this" : FormatColumns("{member}",fk.PrimaryColumns,", ",""));
vlnProperty(sItem+sAlias, MemberName("My" + sItem)+sAlias,"My" + sItem + sAlias,
- " = null;","Related Field" + Debug("20070501.1"),true,false,true,fk,sCheck,null);
+ " = null;","Related Field" + Debug("20070501.1"),true,false,true,fk,sCheck,null,null);
bool bReq = !fk.ForeignColumns[0].IsNullable;
- sExtDirty += string.Format(" || ({0} == null? false : {0}.IsDirty)",MemberName("My" + sItem+sAlias));
- sExtValid += string.Format(" && ({0} == null? true : {0}.IsValid)",MemberName("My" + sItem+sAlias));
+ sExtDirty += string.Format(" || ({0} == null ? false : {0}.IsDirtyList(list))",MemberName("My" + sItem+sAlias));
+ sExtValid += string.Format(" && ({0} == null ? true : {0}.IsValid)",MemberName("My" + sItem+sAlias));
}
}
else //
{
- if(IsPrimaryKey1(fk) && !IsPrimaryKey(fk)){
+ if (IsPrimaryKey1(fk) && !IsPrimaryKey(fk)){
bool bReq = !fk.ForeignColumns[0].IsNullable;
string sClass = ClassName(fk.PrimaryTable.Name) + GetNewAlias(fk,fk);
//sExtDirty += string.Format(" || ({0} == null? " + bReq.ToString().ToLower() + " : {0}.IsDirty)",MemberName("My" + sClass));
//sExtValid += string.Format(" && ({0} == null? " + (!bReq).ToString().ToLower() + " : {0}.IsValid)",MemberName("My" + sClass));
- sExtDirty += string.Format(" || ({0} == null? false : {0}.IsDirty)",MemberName("My" + sClass));
- sExtValid += string.Format(" && ({0} == null? true : {0}.IsValid)",MemberName("My" + sClass));
+ sExtDirty += string.Format(" || ({0} == null ? false : {0}.IsDirtyList(list))",MemberName("My" + sClass));
+ sExtValid += string.Format(" && ({0} == null ? true : {0}.IsValid)",MemberName("My" + sClass));
}
}
}
- if(sExtDirty!="")vlnDirty(sExtDirty);
- //if(sExtValid!="")vlnOverride("Valid",sExtValid);
+ //if (sExtDirty!="")
+ vlnDirty(sExtDirty);
+ //if (sExtValid!="")vlnOverride("Valid",sExtValid);
vlnValid(sExtValid);
// }
// }
}
private void vlnDirty(string sExtension)
{
+ if(sExtension == "")
+ {
%>
public override bool IsDirty
{
- get { return base.IsDirty<%=sExtension%>; }
+ get { return base.IsDirty; }
+ }
+ public bool IsDirtyList(List