【发布时间】:2022-01-02 14:57:29
【问题描述】:
我需要为我的 Country 实体生成 C# 代码,该代码将从提供强类型参数的基实体类继承,以表示我的 PK (@id) 属于 Guid 类型,即基类上的 Id 属性具有隐式类型 Guid。 所以我有两个问题:
-
telosys 中没有 Guid 类型。
-
如何使用通用基类类型化参数定义 PK?
public class Country : Entity<Guid>
{
}
public abstract class Entity<TKey> : Entity, IEntity<TKey>
{
public virtual TKey Id { get; protected set; }
protected Entity(TKey id)
{
Id = id;
}
}
https://www.telosys.org/dsl-syntax.html
. binary
. boolean
. byte
. date
. decimal
. double
. float
. int
. long
. short
. string
. time
. timestamp
https://doc.telosys.org/dsl-model/tags
例如一个特殊的属性名称:metaproperty 我可以解析得到 $entity 继承类型的参数。我需要其他元数据。 实体类作为Id属性,可以是string、int、long等
User {
metaproperty: string {#base
@Label("typed_param:Guid;name:Id;form_sections:Info section~1|Contact sec~2;display_layout:rows(n)_cols(12)")}
FirstName : string {@Label("form_section:~1;display_layout:row(1)col(1)colspan(3)")};
LastName: string {@Label("form_section:~1;display_layout:row(1)col(2)colspan(9)")};
Phone: string {@Label("form_section:~2;display_layout:row(1)col(1)colspan(12)")};
}
I need some mechanizam to display the layout of fields in the form for each property I want in view/edit screens
I can certaily generate some .json structure and add metadata there as well. Even have a GUI with drag and drop feature to define rows, cols and row or col spans.
【问题讨论】:
-
你不能制作自己的 Guid 类吗?
-
什么是 telosys ?上课?
-
如果我正确理解您的需求,Telosys 中的“类型”不是问题(类型用于属性),更多的是关于如何表达“国家”类必须扩展“实体" ?
-
供参考:Telosys 是一个代码生成器 (telosys.org)
-
@Igu。你说的对。它是关于 telosys 可以提供的元数据。这是dsl模型的语法:telosys.org/dsl-syntax.html