diff options
| author | Roy <roy.mail.net@gmail.com> | 2018-01-27 17:18:10 +0200 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2018-01-27 17:18:10 +0200 |
| commit | 20482140c124fd1d5caaffcc9b0dfe853b30dd6f (patch) | |
| tree | 90ddae2089b030833cac9f008767d2b8f96c577f /Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFile.cshtml | |
| parent | 7426c54072d63e49eae8a8a9b9a1097c9ecefbd2 (diff) | |
| download | Tango-20482140c124fd1d5caaffcc9b0dfe853b30dd6f.tar.gz Tango-20482140c124fd1d5caaffcc9b0dfe853b30dd6f.zip | |
Re-factored DAL Observables using EF Code First !!!!!!
Diffstat (limited to 'Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFile.cshtml')
| -rw-r--r-- | Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFile.cshtml | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFile.cshtml b/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFile.cshtml index 709da7dda..001a2bb3f 100644 --- a/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFile.cshtml +++ b/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFile.cshtml @@ -1,13 +1,15 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using Tango.DAL.Remote.DB; namespace Tango.DAL.Observables { - [EntityFieldName("@(Model.TableName)")] - public partial class @(Model.Name) : ObservableEntity<@(Model.EntityName)> + [Table("@(Model.TableName)")] + public partial class @(Model.Name) : ObservableEntity { @foreach (var prop in Model.Fields) { @@ -16,8 +18,9 @@ namespace Tango.DAL.Observables /// <summary> /// Gets or sets the @(Model.Name.ToLower()) @(prop.Description). /// </summary> - [EntityFieldName("@(prop.FieldName)")] - public @(prop.Type) @(prop.Name) + @(!prop.Construct && !prop.Complex ? "[Column(\"" + prop.FieldName + "\")]" : "") + @(prop.IsForeignKey ? "[ForeignKey(\"" + prop.ForeignKeyName + "\")]" : "") + public @(prop.Construct || prop.Complex ? "virtual" : "") @(prop.Type) @(prop.Name) { get { return _@(prop.Name.ToLower()); } set { _@(prop.Name.ToLower()) = value; RaisePropertyChanged(nameof(@(prop.Name))); } @@ -30,31 +33,13 @@ namespace Tango.DAL.Observables /// </summary> public @(Model.Name)() : base() { - Init(); - } - - /// <summary> - /// Initializes a new instance of the <see cref="@(Model.Name)" /> class. - /// </summary> - /// <param name="entity">The entity.</param> - public @(Model.Name)(@(Model.EntityName) entity) : base(entity) - { - Init(); - MapEntityToObservable(entity, this); - } - - /// <summary> - /// Initialize complex types. - /// </summary> - private void Init() - { @foreach (var prop in Model.Fields) { if (prop.Construct) - { - <div> - @(prop.Name) = new @(prop.Type)(); - </div> + { + <div> + @(prop.Name) = new @(prop.Type)(); + </div> } } } |
