私はこのブログの記事(http://marekblotny.blogspot.com/2009/04/conventions-after-rewrite.html)で見たパターンが好きです。ここでは、慣習を適用する前にテーブル名の変更が既に行われているかどうかを確認しています。流暢NHibernte改正/表記
public bool Accept(IClassMap target)
{
//apply this convention if table wasn't specified with WithTable(..) method
return string.IsNullOrEmpty(target.TableName);
}
私は文字列の長さのために使用している大会インタフェースは、IPropertyです:
public class DefaultStringLengthConvention: IPropertyConvention
{
public bool Accept(IProperty property) {
//apply if the string length hasn't been already been specified
return ??; <------ ??
}
public void Apply(IProperty property) {
property.WithLengthOf(50);
}
}
IPropertyプロパティが既に設定されている場合、私に語ったものを公開している、私は表示されません。これは可能ですか?
TIA、
Berryl
考え。私は文字列の長さのグループのための規則を追加しても構わないが、多くの場合は実際にクラスによって駆動される一回限りである。 EmployeeNumber文字列の長さが6文字の場合は、1つのフィールドのEmployeeNumberStringLengthConventionかDefaultStringLengthConventionのif文のいずれかになります。 クイックレスポンスのThx。 – Berryl