本文整理汇总了C#中IPropertyInstance.Unique方法的典型用法代码示例。如果您正苦于以下问题:C# IPropertyInstance.Unique方法的具体用法?C# IPropertyInstance.Unique怎么用?C# IPropertyInstance.Unique使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPropertyInstance
的用法示例。
在下文中一共展示了IPropertyInstance.Unique方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
/// <summary>
/// Conventions for handling string properties in FluentNHibernate. If the property name contains any of the
/// configured strings in BigStringPropertyNames, then the SQL type of the property is set to NVARCHAR(MAX); the
/// SQL type can be overridden by the BigStringSqlType configuration key. Also adds a unique constraint for
/// domain ids and external ids.
/// </summary>
public void Apply(IPropertyInstance instance)
{
// If property name contains one of the configured values, then use use special SQL type for column
string name = instance.Name;
if (bigStringPropertyNames.FirstOrDefault(name.Contains) != null) instance.CustomSqlType(bigStringSqlType);
// Add unique constraint for domain ids and external ids
if (name.Equals("DomainId")) instance.Unique();
if (name.Equals("ExternalId")) instance.Unique();
}
示例2: Apply
public void Apply(IPropertyInstance instance)
{
foreach (object attribute in instance.Property.MemberInfo.GetCustomAttributes(true))
if (attribute is UniqueAttribute)
instance.Unique();
}