Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
eee1169
FullStack takes any column's name: one named like a member it generat…
ejsmith Nov 26, 2026
36d79b1
LookupEnums and Csla warn whoever generates with CodeTemplate.Warning…
ejsmith Nov 26, 2026
98d0217
Legacy README: PLINQO's entity files can use today's C# and VB (=> me…
ejsmith Nov 26, 2026
199e687
Csla: a schema snapshot's web app is wired for the database it was ta…
ejsmith Nov 26, 2026
f23d4f8
Merge branch 'fix/codefileparser-modern-csharp' into fix/pending-2026…
ejsmith Nov 26, 2026
fbf6967
ModernEntities' EF Core templates (and FullStack's and Csla's copies)…
ejsmith Nov 26, 2026
887a5f8
ModernEntities' EF Core templates (and FullStack's and Csla's copies)…
ejsmith Nov 26, 2026
32a58d3
PLINQO's Entities.cst keeps each member of an entity's Metadata class…
ejsmith Nov 26, 2026
76427d9
PLINQO's Dbml.cst fills in the dbml's default values (Mode="Connectio…
ejsmith Nov 26, 2026
812e7a5
PLINQO-EF-DbContext's sample Petshop.csp no longer sets IgnoreList an…
ejsmith Nov 26, 2026
05a94c2
PLINQO: README.md describes the templates and the Metadata class (wha…
ejsmith Nov 26, 2026
f780a4f
FullStack's and Csla's labels come from one routine, NameWords.Label,…
ejsmith Nov 26, 2026
e0f9850
TableToClass's Records.cst and ModernEntities' (and FullStack's) Enti…
ejsmith Nov 26, 2026
08e58ce
FullStack takes a real schema: PostgreSQL arrays are lists, bit strin…
ejsmith Nov 26, 2026
97ee589
Csla takes a real database's schema: arrays are read-only lists CSLA'…
ejsmith Nov 26, 2026
3fc805e
DBDocumenter's title and server are the database's name and the serve…
ejsmith Nov 26, 2026
98c0379
ModernEntities' README says what the configurations map for each data…
ejsmith Nov 26, 2026
a184fc0
Merge branch 'fix/d4-csla' into fix/pending-2026-11-25
ejsmith Nov 26, 2026
34e7b5b
Merge branch 'fix/d4-fullstack' into fix/pending-2026-11-25
ejsmith Nov 26, 2026
bff214e
Merge branch 'fix/d4-plinqo' into fix/pending-2026-11-25
ejsmith Nov 26, 2026
0009ba3
FullStack README: a nullable column with a database default gets it o…
ejsmith Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Csla takes a real database's schema: arrays are read-only lists CSLA'…
…s undo can copy (MobileList) and a list field, bit(n) a string of 0s and 1s, enums a select (a SET check boxes), a key a route has no type for (MySQL's unsigned keys) is parsed by its page, a junction table's parent is the table its key starts with (in column order, the same from every database), a type made for a table gives way to another table's of that name (ProductReadOnlyInfo), Exclude leaves a table out of the EF Core layer too, a page that fails logs it and says why the database refused (with its words in Development), generating warns about what the app does differently, and the README's "Your own database" lists every step, with a "Supported, and not" table
  • Loading branch information
ejsmith committed Nov 26, 2026
commit 97ee58977e266989a26dab37eee21f2db8e7d7b4
64 changes: 60 additions & 4 deletions Templates/Frameworks/Csla/Csla.cst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%@ Property Name="Namespace" Type="System.String" Default="MyApp" Category="Output" Description="The root namespace and the projects' names: {Namespace}.Business, {Namespace}.Dal, {Namespace}.Dal.EfCore and {Namespace}.Web." %>
<%@ Property Name="ContextName" Type="System.String" Default="AppDbContext" Category="Output" Description="The DbContext's class name." %>
<%@ Property Name="OutputDirectory" Type="System.String" Default="." Category="Output" Description="The folder of the four projects: each one's generated files go to its Generated folder." %>
<%@ Property Name="Exclude" Type="System.String" Default="sysdiagrams, __EFMigrationsHistory" Optional="True" Category="Model" Description="Tables (Orders) and columns (Orders.Notes) to leave out, separated by commas; * and ? match any characters." %>
<%@ Property Name="Exclude" Type="System.String" Default="sysdiagrams, __EFMigrationsHistory" Optional="True" Category="Model" Description="Tables (Orders) and columns (Orders.Notes) to leave out, separated by commas; * and ? match any characters. An excluded table has no EF Core entity either." %>
<%@ Property Name="Children" Type="System.String" Default="" Optional="True" Category="Model" Description="Tables to make children of another, besides those the keys say (Parent: Child, Child; Parent: Child)." %>
<%@ Property Name="TargetFramework" Type="System.String" Default="net10.0" Category="Projects" Description="A project file's target framework, where it writes one (a project that isn't there)." %>
<%@ Property Name="CslaVersion" Type="System.String" Default="10.2.0" Category="Projects" Description="The Csla package's version, where it writes the business objects' project (9.x works too)." %>
Expand Down Expand Up @@ -171,22 +171,26 @@ private void Generate(Model model)
dalCommon.Namespace = Namespace;
Render(dalCommon, dal, "Dal");

// the entities: every table's (the DbContext has them all), as the ModernEntities sample generates them
foreach (TableSchema table in SourceDatabase.Tables)
// the entities: every table's but those excluded (the DbContext has them all, a table without a key too), as the
// ModernEntities sample generates them
foreach (TableSchema table in Names.Tables(SourceDatabase, Exclude))
{
var entity = Create<EntityTemplate>();
entity.Table = table;
entity.Namespace = Namespace + ".Dal.EfCore";
entity.Exclude = Exclude;
Render(entity, efCore, Names.Entity(table));
var configuration = Create<ConfigurationTemplate>();
configuration.Table = table;
configuration.Namespace = Namespace + ".Dal.EfCore";
Render(configuration, efCore, Names.Entity(table) + "Configuration");
configuration.Exclude = Exclude;
Render(configuration, efCore, Names.Configuration(table));
}
var context = Create<ContextTemplate>();
context.SourceDatabase = SourceDatabase;
context.Namespace = Namespace + ".Dal.EfCore";
context.ContextName = ContextName;
context.Exclude = Exclude;
Render(context, efCore, ContextName);

var efCommon = Create<EfCommonTemplate>();
Expand All @@ -200,6 +204,8 @@ private void Generate(Model model)
foreach (string directory in new[] { business, dal, efCore, web })
RemoveStale(directory, written);

Warn(model);

// a project file for each, where there isn't one yet: a new database's projects build as they are
var (provider, database) = Database(webProject);
foreach (var (kind, project) in new[] { ("Business", ".Business"), ("Dal", ".Dal"), ("EfCore", ".Dal.EfCore"), ("Web", ".Web") })
Expand Down Expand Up @@ -241,6 +247,56 @@ private void Generate(Model model)
}
}

// What the schema has that the app can't do as it is, and what it does instead: a warning each (CSG0007; VS Code's
// Problems), as Model.md lists them too.
private void Warn(Model model)
{
var keyless = SourceDatabase.Tables.Cast<TableSchema>().Where(t => !t.HasPrimaryKey && !Names.Excluded(t, Exclude)).Select(t => t.Name).ToList();
if (keyless.Count > 0)
Warning(Model.And(keyless) + (keyless.Count == 1 ? " has" : " have") + " no primary key: no business objects or pages, as an object couldn't save a row (its EF Core entity is there, keyless).");
var views = SourceDatabase.Views.Cast<ViewSchema>().Select(v => v.Name).ToList();
if (views.Count > 0)
Warning("The " + (views.Count == 1 ? "view " : "views ") + Model.And(views) + (views.Count == 1 ? " has" : " have") + " no business objects or pages: Csla.cst generates from tables (a read-only list of a view is yours to add).");
// a type that gave way to a table's of its name
var renamed = new List<string>();
foreach (TableSchema table in model.Tables)
{
string name = Model.Class(table);
foreach (var (type, usual, what) in new[]
{
(Model.InfoName(table), name + "Info", "read-only object"), (Model.ListName(table), name + "List", "read-only list"),
(Model.Dto(table), name + "Dto", "DTO"), (Model.Dal(table), name + "Dal", "DAL"), (Names.Configuration(table), name + "Configuration", "EF Core configuration"),
})
if (type != usual)
renamed.Add($"{Model.Possessive(name)} {what} is {type}: {usual} is another table's");
if (name.EndsWith("Entity") && !CodeSmith.Engine.StringUtil.ToPascalCase(table.Name).EndsWith("Entity"))
renamed.Add($"{Model.Possessive(table.Name)} object is {name}: {name.Substring(0, name.Length - "Entity".Length)} is a type the generated code uses");
}
foreach (string clash in renamed)
Warning("A name gives way: " + clash + ".");
// an object named like a type of the web app's shell (Issue, Problem, Lookup): the pages import both
string shell = Path.Combine(CodeTemplateInfo.DirectoryName, "Web", "Shell");
var shellTypes = new HashSet<string>(Directory.GetFiles(shell, "*.cs", SearchOption.AllDirectories)
.SelectMany(f => System.Text.RegularExpressions.Regex.Matches(File.ReadAllText(f), @"^\s*(?:public |internal )?(?:sealed |static |abstract )*(?:partial )?(?:class|record|struct|enum|interface) (\w+)", System.Text.RegularExpressions.RegexOptions.Multiline)
.Cast<System.Text.RegularExpressions.Match>().Select(m => m.Groups[1].Value))
.Concat(Directory.GetFiles(shell, "*.razor", SearchOption.AllDirectories).Select(Path.GetFileNameWithoutExtension))) { "Site" };
foreach (TableSchema table in model.Tables)
foreach (string type in new[] { Model.Class(table), model.IsChild(table) ? Model.ChildList(table) : Model.InfoName(table) }.Where(shellTypes.Contains))
Warning($"{Model.Possessive(table.Name)} {type} has the name of a type of the web app's shell (Components/): its pages won't build until you rename the shell's {type}, or exclude the table.");
// the columns a form can't edit: kept as they are when a row's saved
var unmapped = model.Tables.SelectMany(t => t.Columns.Cast<ColumnSchema>().Where(c => !Names.Mapped(c)).Select(c => $"{t.Name}.{c.Name} ({c.NativeType})")).ToList();
if (unmapped.Count > 0)
Warning(Model.And(unmapped) + (unmapped.Count == 1 ? " has" : " have") + " no .NET type: no property, as EF Core can't map one (map it in a partial class of your own); a save leaves it as it is.");
var notOnForm = model.Tables.SelectMany(t => model.Columns(t).Where(c => model.Settable(c) && Web.KindOf(model, c) == Web.Kind.Unsupported)
.Select(c => $"{t.Name}.{c.Name} ({c.NativeType})")).ToList();
if (notOnForm.Count > 0)
Warning(Model.And(notOnForm) + (notOnForm.Count == 1 ? " isn't" : " aren't") + " on the forms: the pages have no input for " + (notOnForm.Count == 1 ? "its" : "their") + " type; the objects have " + (notOnForm.Count == 1 ? "it" : "them") + ", and a save keeps the value.");
foreach (TableSchema table in model.Tables.Where(t => !model.IsChild(t)))
model.ListCriteria(table);
foreach (string note in model.Notes.Distinct().Where(n => n.Contains(" has no fetch ")))
Warning(note.Replace("`", ""));
}

// A page you've written: a .razor of the generated page's name in the web project, outside Generated/ (Pages/OrderEditPage.razor).
private static bool Replaced(string webProject, string file) =>
Directory.Exists(webProject) &&
Expand Down
10 changes: 5 additions & 5 deletions Templates/Frameworks/Csla/Editable.cst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
// </auto-generated>
#nullable enable
<% if (model.Columns(Table).Any(c => Model.NotNull(c) != "") || children.Count > 0) { %>
// GetProperty(...)! for a <%= model.Columns(Table).Any(c => Model.NotNull(c) != "") ? "string" : "child list" %>, which CSLA keeps non-null (as CSLA's own source generator writes it; CSLA0007 doesn't
// GetProperty(...)! for a <%= model.Columns(Table).Any(c => Model.NotNull(c) != "") ? (model.Columns(Table).Any(Model.IsList) ? "string or a list" : "string") : "child list" %>, which CSLA keeps non-null (as CSLA's own source generator writes it; CSLA0007 doesn't
// know the operator)
#pragma warning disable CSLA0007
<% } %>
Expand All @@ -53,7 +53,7 @@ namespace <%= Namespace %>.Business;
public partial class <%= name %> : BusinessBase<<%= name %>>
{
<% foreach (ColumnSchema column in columns) { %>
public static readonly PropertyInfo<<%= Model.Type(column) %>> <%= Model.Info(column) %> = RegisterProperty<<%= Model.Type(column) %>>(nameof(<%= Model.Property(column) %>));
public static readonly PropertyInfo<<%= Model.FieldType(column) %>> <%= Model.Info(column) %> = RegisterProperty<<%= Model.FieldType(column) %>>(nameof(<%= Model.Property(column) %>));
<% if (Model.Generated(column)) { %>
/// <summary><%= Model.Identity(column) ? "The database numbers it when it's saved." : "The database sets it." %></summary>
<% } else if (model.FromParent(column)) { %>
Expand All @@ -66,9 +66,9 @@ public partial class <%= name %> : BusinessBase<<%= name %>>
{
get => GetProperty(<%= Model.Info(column) %>)<%= Model.NotNull(column) %>;
<% if (model.Settable(column)) { %>
set => SetProperty(<%= Model.Info(column) %>, value);
set => SetProperty(<%= Model.Info(column) %>, <%= Model.ToField(column, "value") %>);
<% } else { %>
private set => LoadProperty(<%= Model.Info(column) %>, value);
private set => LoadProperty(<%= Model.Info(column) %>, <%= Model.ToField(column, "value") %>);
<% } %>
}

Expand Down Expand Up @@ -243,7 +243,7 @@ public partial class <%= name %> : BusinessBase<<%= name %>>
private void Load(<%= dto %> data)
{
<% foreach (ColumnSchema column in columns) { %>
LoadProperty(<%= Model.Info(column) %>, <%= Model.FromDto(column, "data." + Model.Property(column)) %>);
LoadProperty(<%= Model.Info(column) %>, <%= Model.ToField(column, Model.FromDto(column, "data." + Model.Property(column))) %>);
<% } %>
}

Expand Down
2 changes: 1 addition & 1 deletion Templates/Frameworks/Csla/EfDal.cst
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private string DescendantOf(Model model, TableSchema descendant)
var t = model.Table(descendant);
while (!Same(model.Parent(t), Table))
{
path += Names.Navigation(model.ParentKey(t)) + ".";
path += Names.Navigation(model.ParentKey(t), Exclude) + ".";
t = model.Parent(t);
}
var key = model.ParentKey(t);
Expand Down
6 changes: 3 additions & 3 deletions Templates/Frameworks/Csla/Info.cst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// </auto-generated>
#nullable enable
<% if (model.Columns(Table).Any(c => Model.NotNull(c) != "")) { %>
// GetProperty(...)! for a string, which CSLA keeps non-null (as CSLA's own source generator writes it; CSLA0007 doesn't
// GetProperty(...)! for a string<%= model.Columns(Table).Any(Model.IsList) ? " or a list" : "" %>, which CSLA keeps non-null (as CSLA's own source generator writes it; CSLA0007 doesn't
// know the operator)
#pragma warning disable CSLA0007
<% } %>
Expand All @@ -35,12 +35,12 @@ namespace <%= Namespace %>.Business;
public partial class <%= name %> : ReadOnlyBase<<%= name %>>
{
<% foreach (ColumnSchema column in model.Columns(Table)) { %>
public static readonly PropertyInfo<<%= Model.Type(column) %>> <%= Model.Info(column) %> = RegisterProperty<<%= Model.Type(column) %>>(nameof(<%= Model.Property(column) %>));
public static readonly PropertyInfo<<%= Model.FieldType(column) %>> <%= Model.Info(column) %> = RegisterProperty<<%= Model.FieldType(column) %>>(nameof(<%= Model.Property(column) %>));
[Display(Name = "<%= Model.Friendly(column) %>")]
public <%= Model.Type(column) %> <%= Model.Property(column) %>
{
get => GetProperty(<%= Model.Info(column) %>)<%= Model.NotNull(column) %>;
private set => LoadProperty(<%= Model.Info(column) %>, value);
private set => LoadProperty(<%= Model.Info(column) %>, <%= Model.ToField(column, "value") %>);
}

<% } %>
Expand Down
Loading