0

Visual Studio の Edmx デザイナーに非常によく似たデザイナーに取り組んでいます。Edmx デザイナーがエンティティ名とプロパティ名に適用するのと同じ検証を追加したいと考えています。誰かが検証ルールとは何か、つまり許可されている文字と許可されていない文字を共有できますか? エンティティ/プロパティ名の長さおよびその他のそのような規則は?

4

1 に答える 1

0

Look at the xsds. When loading artifacts (CSDL/MSL/SSDL) there is two step validation 1 - using xsd, 2 internal validation checking additional rules that in most cases cannot be expressed in xsd. EF6 is open source now but xsd schemas for previous versions have not changed. You can find them here. (Schemas for mapping are in the MappingSpecification folder).

If you look at v3 CSDL schema the name of the property is specified as follows:

<xs:simpleType name="TSimpleIdentifier">
    <xs:restriction base="xs:string">
        <xs:maxLength value="480" />
        <!-- The below pattern represents the allowed identifiers in ECMA specification -->
        <xs:pattern value="[\p{L}\p{Nl}][\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}]{0,}" />
    </xs:restriction>
</xs:simpleType>

If you don't want to bother with xsds and would like to take advantage of the internal validation you can just load your xml to the corresponding item collection. Again in EF6 there have been some overloads added that allows you load artifacts but will not throw an exception if they are invalid but would return null and a list of errors as an out parameter (look for public static factory methods on item collections).

于 2013-03-27T20:00:19.323 に答える