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

telosys c# CRUD generation and skipping already existing classes - Stack Overflow

programmeradmin6浏览0评论

I am working with telosys 4.2.0 in C#. I have added 7 c# templates in csharp-bundle:

Entity class;${BEANNAME}.cs;Models;entity_cs.vm;*
Controller;${BEANNAME}Controller.cs;Controllers;controller_cs.vm;*
Service;${BEANNAME}Service.cs;Services;service_cs.vm;*
Interface;IGenericRepository.cs;Repositories;igenericrepository_cs.vm;
Repository;Repository.cs;Repositories;repository_cs.vm;
UnitOfWork;UnitOfWork.cs;UnitOfWork;unitofwork_cs.vm;
Interface;IUnitOfWork.cs;UnitOfWork;iunitofwork_cs.vm;

Last four template config are not entity specific. I want them to generate only once. If I run "gen Product *" it generates 7 files. Is there any way, for new entity, if I run "gen Order *" last 4 template classes won't overwrite.

Additionally * target is not behaving as expected. 3 templates are flagged with *, and last 4 missing * target. But "gen Product *" generating all 7 templates classes.

I am able to generate a single class using "gen Product UnitOfWork.vm". But is there any -ifnew flag present in telosys 4.2.0 to skip existing classes' generation while using "gen Product *" or "gen * *"?

I am working with telosys 4.2.0 in C#. I have added 7 c# templates in csharp-bundle:

Entity class;${BEANNAME}.cs;Models;entity_cs.vm;*
Controller;${BEANNAME}Controller.cs;Controllers;controller_cs.vm;*
Service;${BEANNAME}Service.cs;Services;service_cs.vm;*
Interface;IGenericRepository.cs;Repositories;igenericrepository_cs.vm;
Repository;Repository.cs;Repositories;repository_cs.vm;
UnitOfWork;UnitOfWork.cs;UnitOfWork;unitofwork_cs.vm;
Interface;IUnitOfWork.cs;UnitOfWork;iunitofwork_cs.vm;

Last four template config are not entity specific. I want them to generate only once. If I run "gen Product *" it generates 7 files. Is there any way, for new entity, if I run "gen Order *" last 4 template classes won't overwrite.

Additionally * target is not behaving as expected. 3 templates are flagged with *, and last 4 missing * target. But "gen Product *" generating all 7 templates classes.

I am able to generate a single class using "gen Product UnitOfWork.vm". But is there any -ifnew flag present in telosys 4.2.0 to skip existing classes' generation while using "gen Product *" or "gen * *"?

Share Improve this question edited Mar 26 at 12:57 saibin asked Mar 26 at 12:17 saibinsaibin 254 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

If you want a template to be executed only once (not for all entities)
add "1" at the end instead of "*"
Example:
; _Layout.cshtml ; ${SRC}/Views/Shared ; Views/Shared/_Layout_cshtml.vm ; 1

If you don't want to rewrite a target file if it already exists
add this directive at the beginning of your template :
#if($target.outputFileExists() )#cancel("File already exists")#end

发布评论

评论列表(0)

  1. 暂无评论