小编WPF*_*mer的帖子

如何检查T4模板文件中实体的属性的数据类型

我在EF 4.0中自定义我的.tt文件.现在作为自定义的一部分,我需要在POCO类生成中向属性添加一些代码,如果属性类型是Nullable<System.DateTime>System.DateTime.我无法找到适当的比较语法.

我在.tt文件中有以下代码.

foreach (EdmProperty edmProperty in entity.Properties.Where(p => p.TypeUsage.EdmType is PrimitiveType && p.DeclaringType == entity))
{
bool isDefaultValueDefinedInModel = (edmProperty.DefaultValue != null);
//Here I need to check whether my edmProperty is Nullable<System.DateTime> or System.DateTime, so that I can insert custom code.
}
Run Code Online (Sandbox Code Playgroud)

请帮忙.

c# t4 templates entity entity-framework

9
推荐指数
1
解决办法
6981
查看次数

标签 统计

c# ×1

entity ×1

entity-framework ×1

t4 ×1

templates ×1