本文整理汇总了C#中SchemaBuilder.AddUniqueIndex方法的典型用法代码示例。如果您正苦于以下问题:C# SchemaBuilder.AddUniqueIndex方法的具体用法?C# SchemaBuilder.AddUniqueIndex怎么用?C# SchemaBuilder.AddUniqueIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SchemaBuilder
的用法示例。
在下文中一共展示了SchemaBuilder.AddUniqueIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public static void Start(SchemaBuilder sb)
{
if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
{
sb.Include<PropertyRouteEntity>();
sb.AddUniqueIndex<PropertyRouteEntity>(p => new { p.Path, p.RootType });
sb.Schema.Synchronizing += SyncronizeProperties;
}
}
示例2: Start
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
{
if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
{
sb.Include<TranslationReplacementEntity>();
sb.AddUniqueIndex<TranslationReplacementEntity>(tr => new { tr.CultureInfo, tr.WrongTranslation });
dqm.RegisterQuery(typeof(TranslationReplacementEntity), () =>
from e in Database.Query<TranslationReplacementEntity>()
select new
{
Entity = e,
e.Id,
e.CultureInfo,
e.WrongTranslation,
e.RightTranslation,
});
new Graph<TranslationReplacementEntity>.Execute(TranslationReplacementOperation.Save)
{
AllowsNew = true,
Lite = false,
Execute = (e, _) => { },
}.Register();
new Graph<TranslationReplacementEntity>.Delete(TranslationReplacementOperation.Delete)
{
Delete = (e, _) => { e.Delete(); },
}.Register();
ReplacementsLazy = sb.GlobalLazy(() => Database.Query<TranslationReplacementEntity>()
.AgGroupToDictionary(a => a.CultureInfo.ToCultureInfo(),
gr =>
{
var dic = gr.ToDictionary(a => a.WrongTranslation, a => a.RightTranslation, StringComparer.InvariantCultureIgnoreCase, "wrong translations");
var regex = new Regex(dic.Keys.ToString(Regex.Escape, "|"), RegexOptions.IgnoreCase);
return new TranslationReplacementPack { Dictionary = dic, Regex = regex };
}),
new InvalidateWith(typeof(TranslationReplacementEntity)));
}
}
示例3: Start
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
{
if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
{
FileTypeLogic.Start(sb, dqm);
sb.Include<FilePathEntity>();
sb.Schema.EntityEvents<FilePathEntity>().Retrieved += FilePathLogic_Retrieved;
sb.Schema.EntityEvents<FilePathEntity>().PreSaving += FilePath_PreSaving;
sb.Schema.EntityEvents<FilePathEntity>().PreUnsafeDelete += new PreUnsafeDeleteHandler<FilePathEntity>(FilePathLogic_PreUnsafeDelete);
dqm.RegisterQuery(typeof(FilePathEntity), () =>
from p in Database.Query<FilePathEntity>()
select new
{
Entity = p,
p.Id,
p.FileName,
p.FileType,
p.Sufix
});
new Graph<FilePathEntity>.Execute(FilePathOperation.Save)
{
AllowsNew = true,
Lite = false,
Execute = (fp, _) =>
{
if (!fp.IsNew)
{
var ofp = fp.ToLite().Retrieve();
if (fp.FileName != ofp.FileName || fp.Sufix != ofp.Sufix || fp.FullPhysicalPath != ofp.FullPhysicalPath)
{
using (Transaction tr = new Transaction())
{
var preSufix = ofp.Sufix.Substring(0, ofp.Sufix.Length - ofp.FileName.Length);
fp.Sufix = Path.Combine(preSufix, fp.FileName);
fp.Save();
System.IO.File.Move(ofp.FullPhysicalPath, fp.FullPhysicalPath);
tr.Commit();
}
}
}
}
}.Register();
sb.AddUniqueIndex<FilePathEntity>(f => new { f.Sufix, f.FileType }); //With mixins, add AttachToUniqueIndexes to field
dqm.RegisterExpression((FilePathEntity fp) => fp.WebImage(), () => typeof(WebImage).NiceName(), "Image");
dqm.RegisterExpression((FilePathEntity fp) => fp.WebDownload(), () => typeof(WebDownload).NiceName(), "Download");
}
}