89 lines
2.3 KiB
Plaintext
89 lines
2.3 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
|
|
@{
|
|
}
|
|
using System;
|
|
using System.Runtime.Serialization;
|
|
using DotNetNuke.ComponentModel.DataAnnotations;
|
|
|
|
namespace @(Settings.RootNameSpace).Models.@(Model.PluralName)
|
|
{
|
|
|
|
[TableName("@Model.Prefix@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) @if (Model.TableAndView){@: : @(Model.SingularName)Base
|
|
}
|
|
{
|
|
|
|
#region .ctor
|
|
public @(Model.SingularName)() @if (Model.TableAndView){@: : base()
|
|
}
|
|
{
|
|
}
|
|
#endregion
|
|
|
|
#region Properties
|
|
@foreach (Column c in Model.UniqueViewColumns)
|
|
{
|
|
@:@Raw(Engine.RunCompile("PropertyField.cshtml", c).TrimEnd('\r', '\n'))
|
|
}
|
|
#endregion
|
|
|
|
#region Methods
|
|
@if (Model.TableAndView)
|
|
{
|
|
@: public @(Model.SingularName)Base Get@(Model.SingularName)Base()
|
|
@: {
|
|
@: @(Model.SingularName)Base res = new @(Model.SingularName)Base();
|
|
foreach (Column c in Model.TableColumns)
|
|
{
|
|
@: res.@c.Name = @c.Name;
|
|
}
|
|
if (Model.HasAuditFields)
|
|
{
|
|
@: res.CreatedByUserID = CreatedByUserID;
|
|
@: res.CreatedOnDate = CreatedOnDate;
|
|
@: res.LastModifiedByUserID = LastModifiedByUserID;
|
|
@: res.LastModifiedOnDate = LastModifiedOnDate;
|
|
}
|
|
@: return res;
|
|
@: }
|
|
}
|
|
public @(Model.SingularName) Clone()
|
|
{
|
|
@(Model.SingularName) res = new @(Model.SingularName)();
|
|
@foreach (Column c in Model.TableColumns)
|
|
{
|
|
@: res.@c.Name = @c.Name;
|
|
}
|
|
@if (Model.TableAndView)
|
|
{
|
|
foreach (Column c in Model.UniqueViewColumns)
|
|
{
|
|
@: res.@c.Name = @c.Name;
|
|
}
|
|
}
|
|
@if (Model.HasAuditFields)
|
|
{
|
|
@: res.CreatedByUserID = CreatedByUserID;
|
|
@: res.CreatedOnDate = CreatedOnDate;
|
|
@: res.LastModifiedByUserID = LastModifiedByUserID;
|
|
@: res.LastModifiedOnDate = LastModifiedOnDate;
|
|
}
|
|
return res;
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
} |