Skip to content

Commit

Permalink
More examples of adding base classes
Browse files Browse the repository at this point in the history
  • Loading branch information
sjh37 committed Apr 25, 2024
1 parent ceb3115 commit 184e488
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
22 changes: 21 additions & 1 deletion BuildTT/BuildTT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,34 @@ private static void CreateTT(string generatorRoot, string ttRoot)
//if (table.NameHumanCase.Equals(""SomeTable"", StringComparison.InvariantCultureIgnoreCase))
// table.AdditionalComment = ""Example comment"";
// To add a base class to a table based on column names. Also see Settings.UpdateColumn below.
// To add a base class to a table based on any of these column names. Also see Settings.UpdateColumn below.
//var tracking = new List<string> { ""createdby"", ""createdon"", ""modifiedby"", ""modifiedon"" };
//var replicate = new List<string> { ""uniqueid"", ""hrid""};
//if (table.Columns.Any(x => tracking.Contains(x.NameHumanCase)))
// table.BaseClasses = "" : TrackingEntity"";
//if (table.Columns.Any(x => replicate.Contains(x.NameHumanCase)))
// table.BaseClasses = "" : ReplicateEntity"";
// To add a base class to a table based on ALL of these column names
//var lookupTitle = new List<string> { ""ID"", ""Title"", ""Description"" };
//if (lookupTitle.All(x => table.Columns.Any(c => c.NameHumanCase == x)))
//{
// if(string.IsNullOrEmpty(table.BaseClasses))
// table.BaseClasses = "" : ILookupTitle"";
// else
// table.BaseClasses += "", ILookupTitle"";
//}
// Add a base class to a table based on its name
//var quickEdit = new List<string> { ""Categories"", ""Customers"", ""Employees"", ""Orders"" };
//if(quickEdit.Any(x => table.NameHumanCase == x))
//{
// if(string.IsNullOrEmpty(table.BaseClasses))
// table.BaseClasses = "" : IQuickEdit"";
// else
// table.BaseClasses += "", IQuickEdit"";
//}
// To add attributes
//table.Attributes.Add(""[Serializable]"");
};
Expand Down
22 changes: 21 additions & 1 deletion EntityFramework.Reverse.POCO.Generator/Database.tt
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,34 @@
//if (table.NameHumanCase.Equals("SomeTable", StringComparison.InvariantCultureIgnoreCase))
// table.AdditionalComment = "Example comment";

// To add a base class to a table based on column names. Also see Settings.UpdateColumn below.
// To add a base class to a table based on any of these column names. Also see Settings.UpdateColumn below.
//var tracking = new List<string> { "createdby", "createdon", "modifiedby", "modifiedon" };
//var replicate = new List<string> { "uniqueid", "hrid"};
//if (table.Columns.Any(x => tracking.Contains(x.NameHumanCase)))
// table.BaseClasses = " : TrackingEntity";
//if (table.Columns.Any(x => replicate.Contains(x.NameHumanCase)))
// table.BaseClasses = " : ReplicateEntity";

// To add a base class to a table based on ALL of these column names
//var lookupTitle = new List<string> { "ID", "Title", "Description" };
//if (lookupTitle.All(x => table.Columns.Any(c => c.NameHumanCase == x)))
//{
// if(string.IsNullOrEmpty(table.BaseClasses))
// table.BaseClasses = " : ILookupTitle";
// else
// table.BaseClasses += ", ILookupTitle";
//}

// Add a base class to a table based on its name
//var quickEdit = new List<string> { "Categories", "Customers", "Employees", "Orders" };
//if(quickEdit.Any(x => table.NameHumanCase == x))
//{
// if(string.IsNullOrEmpty(table.BaseClasses))
// table.BaseClasses = " : IQuickEdit";
// else
// table.BaseClasses += ", IQuickEdit";
//}

// To add attributes
//table.Attributes.Add("[Serializable]");
};
Expand Down

0 comments on commit 184e488

Please sign in to comment.