69 lines
1.6 KiB
Plaintext
69 lines
1.6 KiB
Plaintext
@inherits RazorTemplate<ObjectDefinition>
|
|
@using Bring2mind.CodeGen.Cli.Common
|
|
@using Bring2mind.CodeGen.Cli.Data
|
|
@using Bring2mind.CodeGen.Cli.Razor
|
|
@using Microsoft.SqlServer.Management.Smo
|
|
@{
|
|
dynamic vb = new System.Dynamic.ExpandoObject();
|
|
vb.ObjectName = Model.SingularName;
|
|
|
|
string baseQualifier = "Base";
|
|
if (Model.TableOnly)
|
|
{
|
|
baseQualifier = "";
|
|
}
|
|
|
|
}
|
|
using System;
|
|
using System.Runtime.Serialization;
|
|
using DotNetNuke.ComponentModel.DataAnnotations;
|
|
using @(Settings.RootNameSpace).Data;
|
|
|
|
namespace @(Settings.RootNameSpace).Models.@(Model.PluralName)
|
|
{
|
|
[TableName("@Model.ModuleQualifier@Model.Name")]
|
|
@if (Model.Table.IsTableWithIdColumn())
|
|
{
|
|
@: [PrimaryKey("@Model.Table.PrimaryKeyParameters()", AutoIncrement = true)]
|
|
}
|
|
[DataContract]
|
|
@if (Model.Scope != "")
|
|
{
|
|
@: [Scope("@Model.Scope")]
|
|
}
|
|
public partial class @(Model.SingularName)@baseQualifier @if (Model.HasAuditFields){@: : AuditableEntity
|
|
}
|
|
{
|
|
|
|
#region .ctor
|
|
public @(Model.SingularName)@(baseQualifier)()
|
|
{
|
|
@if (@Model.Table.IsTableWithIdColumn())
|
|
{
|
|
@: @Model.Table.PrimaryKeyParameters() = -1;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Properties
|
|
@foreach (Column c in Model.TableColumns)
|
|
{
|
|
@:@Raw(Engine.RunCompile("PropertyField.cshtml", c))
|
|
}
|
|
#endregion
|
|
|
|
#region Methods
|
|
public void Read@(Model.SingularName)@(baseQualifier)(@(Model.SingularName)@baseQualifier @(Model.SingularName.Lowered()))
|
|
{
|
|
@foreach (Column c in Model.TableColumns)
|
|
{
|
|
@:@Raw(Engine.RunCompile("ReadBaseField.cshtml", c, vb))
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|
|
|