답변

1

DatabaseFirst를 사용한다고 가정하면 프로젝트에 엔터티 클래스를 자동 생성하는 Model.tt 파일이 있어야합니다. 그 안에는 WriteProperty이라는 실제 속성을 생성하는 함수가 있습니다. 바로 속성을 추가 할 수 있습니다. 조건부 속성을 적용해야하는 경우

void WriteProperty(string accessibility, string type, string name, string getterAccessibility, string setterAccessibility) 
{ 
#> 
    [YourCustomFilterAttribute] 
    <#=accessibility#> <#=type#> <#=name#> { <#=getterAccessibility#>get; <#=setterAccessibility#>set; } 
<#+ 
} 

당신은 물론 type, name 및 기타 매개 변수와 함께 놀 수 있었다 : 그것은 다음과 같이 보입니다.

관련 문제