Database Agnostic Model Template with dapper flavour

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
figueiredorj
Posts: 41
Joined: Fri 12 Apr 2013 19:05

Re: Database Agnostic Model Template with dapper flavour

Post by figueiredorj » Wed 23 May 2018 09:19

Hi Shalex,

on current template from line 577 replace current code with

Code: Select all

        #region Properties
<#
      var keyProperties = new List<string>();
      var entityProperties = new List<string>();
      
      foreach (EntityProperty property in cls.Properties){
          entityProperties.Add(property.Name);
          


          GenerateProperty(property);
          }


        
#>
          [NotMapped]
          public string[] EntityProperties { get; } = { <#= entityProperties.Aggregate((prev, next) => string.Format("\"{0}\"",prev) + "," + string.Format("\"{0}\"",prev) ) #> }
        #endregion
<#
this will throw an exception out of memory...
despite that, is this right aproach to add this 2 properties?
thanks

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Database Agnostic Model Template with dapper flavour

Post by Shalex » Thu 24 May 2018 14:18

I still cannot reproduce System.OutOfMemoryException.

1. Please reupload your project (or just the current model and custom template) and specify the exact steps we should follow for reproducing System.OutOfMemoryException.
2. Tell us your current version (x.x.x) of Entity Developer.

figueiredorj
Posts: 41
Joined: Fri 12 Apr 2013 19:05

Re: Database Agnostic Model Template with dapper flavour

Post by figueiredorj » Mon 28 May 2018 10:34

Hi,

actually currently I am also not able to reproduce the out of memory issue...
I got something different now:

Severity Code Description Project File Line Suppression State
Error Syntax error D:\DEMOS\dev.model\dev.Model.Design\DataModel.DbContext.tmpl 577
Error CS0535 'Base' does not implement interface member 'ICustomDataEntity.KeyProperties' dev.Model D:\DEMOS\dev.model\dev.Model\Entities\Base.Generated.cs 28 Active
Error CS0535 'Base' does not implement interface member 'ICustomDataEntity.EntityProperties' dev.Model D:\DEMOS\dev.model\dev.Model\Entities\Base.Generated.cs 28 Active
Error Custom tool error: An error occurred during an attempt to compile the template 'DbContext'.
Error List:
error : ) expected
error : Invalid expression term ')'
error : ; expected
error : Invalid expression term ')'
error : ) expected
error : Invalid expression term ')'
error : ; expected
error : Invalid expression term ')' D:\DEMOS\dev.model\dev.Model.Design\DataModel.DbContext.tmpl 1
Error Close_parens expected D:\DEMOS\dev.model\dev.Model.Design\DataModel.DbContext.tmpl 575
Error Syntax error D:\DEMOS\dev.model\dev.Model.Design\DataModel.DbContext.tmpl 575
Error Syntax error D:\DEMOS\dev.model\dev.Model.Design\DataModel.DbContext.tmpl 575
Error Semicolon expected D:\DEMOS\dev.model\dev.Model.Design\DataModel.DbContext.tmpl 575
Error Close_parens expected D:\DEMOS\dev.model\dev.Model.Design\DataModel.DbContext.tmpl 577
Error Semicolon expected D:\DEMOS\dev.model\dev.Model.Design\DataModel.DbContext.tmpl 577
Error Syntax error D:\DEMOS\dev.model\dev.Model.Design\DataModel.DbContext.tmpl 577


however I was expecting current code to be ok.
https://1drv.ms/u/s!AuhmVET3Qp9ljTu--ArE6TSxyw5i

I have reupload my solution...
errors on 577....

thanks

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Database Agnostic Model Template with dapper flavour

Post by Shalex » Wed 30 May 2018 17:20

You should remove simecolon in case of expression block (begins with <#=).

Starting from the line 575, replace

Code: Select all

        [NotMapped]
        public string[] KeyProperties  => new string[]  { <#= keyProperties.Aggregate((previous, next) => previous + " , " + next); #> };
        [NotMapped]
        public string[] EntityProperties => new string[] { <#=  entityProperties.Aggregate((previous, next) => previous + " , " + next); #> };
with

Code: Select all

        [NotMapped]
        public string[] KeyProperties  => new string[]  { <#= keyProperties.Aggregate((previous, next) => previous + " , " + next) #> };
        [NotMapped]
        public string[] EntityProperties => new string[] { <#=  entityProperties.Aggregate((previous, next) => previous + " , " + next) #> };

Post Reply