2016-04-26 6 views
0

ModelプロパティのAttributes設定の目的は何ですか?プロパティの属性設定の目的

私はsubproducerについて読んだし、ここで説明したものを達成したいと思います:http://www.softfluent.com/product/codefluent-entities/knowledge-center/how-to-add-attributes-to-codefluent-generated-properties

は、プロパティの属性を設定しようとすると、XMLを変更するだろうが、BOMプロデューサーが選んだれませんでした、なぜ何らかの理由があります?

次の例では、MyPropertyプロパティの上に装飾を置くことが予想されていましたが、それは起こりませんでした。あなたの答えのための

おかげで、

<cf:property name="MyProperty" typeName="{0}.Namespace.MyEntity" relationSchema="Schema"> 
     <cf:attribute name="Newtonsoft.Json.JsonIgnore" context="Property" class=""> 
     <cf:argument name="arg1" expression="value1" /> 
     </cf:attribute> 
    </cf:property> 

答えて

1

属性は、BOMのプロデューサーで使用されています。しかし、あなたのニーズに合わないcontextを設定しました。実際にはプロパティはリレーションプロパティなので、context="ToOneRelationKeyProperty, ToOneRelationProperty, ToManyRelationProperty, RelationProperties"(これらの値の1つしか保持しない)またはデフォルト値を使用する必要があります。

<cf:entity name="Customer"> 
    <cf:property name="Id" key="true" /> 
    <cf:property name="Orders" typeName="OrderCollection"> 
    <cf:attribute name="Newtonsoft.Json.JsonIgnore" class="" context="RelationProperties"> 
     <cf:argument name="arg1" expression="value1" /> 
    </cf:attribute> 
    </cf:property> 
</cf:entity> 

BOMプロデューサが生成します。この回答のため

[Newtonsoft.Json.JsonIgnore(arg1=value1)] 
public Model1.OrderCollection Orders 
+0

おかげで、私はコンテキスト定義について認識していませんでした。 –

関連する問題