最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

telosys is not generating model using csharp bundle - Stack Overflow

programmeradmin4浏览0评论

I am trying to generate model from Product.entity using C# bundle.

Key Insight $entity.name Fails: It’s not resolving to Product—the class name was blank in the minimal output. $entity.fields Fails: “No attribute 'fields'” persists, even with a valid Product.entity. Conclusion: The $entity object isn’t being populated correctly—neither name nor fields works, despite Product being recognized (Entities: . Product). This isn’t just a $entity.fields issue—$entity itself is broken in the generator context for both 4.1.1-001 and 4.2.0-001.

Current Error (with #foreach): [ERROR] Invalid reference (entity_cs.vm line 4) $entity.fields : no attribute 'fields'—even in 4.1.1-001.

templates.cfg: Entity class;${BEANNAME}.cs;Models;entity_cs.vm;*  


entity_cs.vm
// Generated on ${now}
namespace TelosysSample.Models {
    public class ${entity.name} {
#foreach ($field in $entity.fields)
        public ${field.type} ${field.name} { get; set; }
#end
    }
}


Product {
    Id : int { @Id };
    Name : string;
    Price : decimal;
    IsAvailable : boolean;
}

I am trying to generate model from Product.entity using C# bundle.

Key Insight $entity.name Fails: It’s not resolving to Product—the class name was blank in the minimal output. $entity.fields Fails: “No attribute 'fields'” persists, even with a valid Product.entity. Conclusion: The $entity object isn’t being populated correctly—neither name nor fields works, despite Product being recognized (Entities: . Product). This isn’t just a $entity.fields issue—$entity itself is broken in the generator context for both 4.1.1-001 and 4.2.0-001.

Current Error (with #foreach): [ERROR] Invalid reference (entity_cs.vm line 4) $entity.fields : no attribute 'fields'—even in 4.1.1-001.

templates.cfg: Entity class;${BEANNAME}.cs;Models;entity_cs.vm;*  


entity_cs.vm
// Generated on ${now}
namespace TelosysSample.Models {
    public class ${entity.name} {
#foreach ($field in $entity.fields)
        public ${field.type} ${field.name} { get; set; }
#end
    }
}


Product {
    Id : int { @Id };
    Name : string;
    Price : decimal;
    IsAvailable : boolean;
}
Share Improve this question edited Mar 24 at 11:56 saibin asked Mar 24 at 11:56 saibinsaibin 254 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You get the error "$entity.fields : no attribute 'fields'"
because indeed "fields" is not a property of "$entity".
You should use "$entity.attributes" instead.
See the documentation for Telosys objects here : https://doc.telosys./bundles/telosys-objects

Example:

#foreach ($attr in $entity.attributes)
    public ${attr.type} ${attr.name} { get; set; }
#end

$entity.name should always work except if there's an error in your template definition in "templates.cfg" with a line ending with "1" (no entity) instead of "*" (for each entity)

发布评论

评论列表(0)

  1. 暂无评论