Skip to content

Commit 37b5be7

Browse files
committed
Class generator change (add table attribute always when DbModel option is selected).
1 parent 4b7b94a commit 37b5be7

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

MsSql.ClassGenerator.Core/Business/ClassManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ private static string GetClassAttributes(ClassGeneratorOptions options, TableEnt
116116
if (options.AddTableNameToClassSummary)
117117
{
118118
attributes.Add(1, "/// <remarks>");
119-
attributes.Add(2, $"/// Table <c>{table.Name}</c>");
119+
attributes.Add(2, $"/// Table <c>[{table.Schema}].[{table.Name}]</c>");
120120
attributes.Add(3, "/// </summary>");
121121
}
122122

123-
if (options.DbModel && !table.Name.Equals(table.ClassName))
123+
if (options.DbModel)
124124
{
125125
attributes.Add(4, string.IsNullOrWhiteSpace(table.Schema)
126126
? $"[Table(\"{table.Name}\")]"
@@ -147,7 +147,7 @@ private string GeneratePropertyCode(ClassGeneratorOptions options, List<string>
147147
var dataType = GetCSharpType(column.DataType);
148148

149149
// Prepare the template
150-
var tmpTemplate = template.ToList(); // We nee a "copy" of the original template.
150+
var tmpTemplate = template.ToList(); // We need a "copy" of the original template.
151151
PrepareTemplate(tmpTemplate, dataType);
152152

153153
// Set the type

MsSql.ClassGenerator/Model/TableColumnDto.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ public sealed partial class TableColumnDto : ObservableObject
1313
/// </summary>
1414
public int Id { get; set; }
1515

16+
/// <summary>
17+
/// Gets or sets the name of the schema.
18+
/// </summary>
19+
/// <remarks>
20+
/// <b>Note</b>: Only needed for the tables.
21+
/// </remarks>
22+
public string Schema { get; set; } = string.Empty;
23+
1624
/// <summary>
1725
/// Gets or sets the name of the table.
1826
/// </summary>
@@ -68,6 +76,7 @@ partial void OnAliasChanged(string value)
6876
public TableColumnDto(TableEntry table)
6977
{
7078
Id = table.Id;
79+
Schema = table.Schema;
7180
Name = table.Name;
7281
Alias = table.Alias;
7382
Columns = table.Columns.Select(s => new TableColumnDto(s)).ToList();

MsSql.ClassGenerator/Ui/View/MainWindow.xaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,16 @@
338338
<DataGridCheckBoxColumn Width="Auto" Binding="{Binding Use}" />
339339
<DataGridTextColumn
340340
Width="*"
341+
Binding="{Binding Schema}"
342+
Header="Schema"
343+
IsReadOnly="True" />
344+
<DataGridTextColumn
345+
Width="2*"
341346
Binding="{Binding Name}"
342347
Header="Name"
343348
IsReadOnly="True" />
344349
<DataGridTextColumn
345-
Width="*"
350+
Width="2*"
346351
Binding="{Binding Alias, UpdateSourceTrigger=PropertyChanged}"
347352
Header="Alias" />
348353
</DataGrid.Columns>

0 commit comments

Comments
 (0)