本文整理汇总了C#中SchemaBuilder.GlobalLazy方法的典型用法代码示例。如果您正苦于以下问题:C# SchemaBuilder.GlobalLazy方法的具体用法?C# SchemaBuilder.GlobalLazy怎么用?C# SchemaBuilder.GlobalLazy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SchemaBuilder
的用法示例。
在下文中一共展示了SchemaBuilder.GlobalLazy方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public static void Start(SchemaBuilder sb)
{
if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
{
// QueryManagers = queryManagers;
sb.Schema.Initializing += () =>
{
queryNamesLazy.Load();
queryNameToEntityLazy.Load();
};
sb.Include<QueryEntity>();
sb.Schema.Synchronizing += SynchronizeQueries;
sb.Schema.Generating += Schema_Generating;
queryNamesLazy = sb.GlobalLazy(()=>CreateQueryNames(), new InvalidateWith(typeof(QueryEntity)));
queryNameToEntityLazy = sb.GlobalLazy(() =>
EnumerableExtensions.JoinStrict(
Database.Query<QueryEntity>().ToList(),
QueryNames,
q => q.Key,
kvp => kvp.Key,
(q, kvp) => KVP.Create(kvp.Value, q),
"caching QueryEntity. Consider synchronize").ToDictionary(),
new InvalidateWith(typeof(QueryEntity)));
}
}
示例2: Start
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
{
if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
{
QueryLogic.Start(sb);
PermissionAuthLogic.RegisterPermissions(UserQueryPermission.ViewUserQuery);
UserAssetsImporter.RegisterName<UserQueryEntity>("UserQuery");
sb.Schema.Synchronizing += Schema_Synchronizing;
sb.Include<UserQueryEntity>();
dqm.RegisterQuery(typeof(UserQueryEntity), () =>
from uq in Database.Query<UserQueryEntity>()
select new
{
Entity = uq,
uq.Query,
uq.Id,
uq.DisplayName,
uq.EntityType,
});
sb.Schema.EntityEvents<UserQueryEntity>().Retrieved += UserQueryLogic_Retrieved;
new Graph<UserQueryEntity>.Execute(UserQueryOperation.Save)
{
AllowsNew = true,
Lite = false,
Execute = (uq, _) => { }
}.Register();
new Graph<UserQueryEntity>.Delete(UserQueryOperation.Delete)
{
Lite = true,
Delete = (uq, _) => uq.Delete()
}.Register();
UserQueries = sb.GlobalLazy(() => Database.Query<UserQueryEntity>().ToDictionary(a => a.ToLite()),
new InvalidateWith(typeof(UserQueryEntity)));
UserQueriesByQuery = sb.GlobalLazy(() => UserQueries.Value.Values.Where(a => a.EntityType == null).GroupToDictionary(a => a.Query.ToQueryName(), a => a.ToLite()),
new InvalidateWith(typeof(UserQueryEntity)));
UserQueriesByType = sb.GlobalLazy(() => UserQueries.Value.Values.Where(a => a.EntityType != null).GroupToDictionary(a => TypeLogic.IdToType.GetOrThrow(a.EntityType.Id), a => a.ToLite()),
new InvalidateWith(typeof(UserQueryEntity)));
}
}
示例3: Start
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
{
if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
{
if (sb.Schema.Tables.ContainsKey(typeof(UserChartEntity)))
throw new InvalidOperationException("UserChart has already been registered");
UserAssetsImporter.RegisterName<UserChartEntity>("UserChart");
sb.Schema.Synchronizing += Schema_Synchronizing;
sb.Include<UserChartEntity>();
dqm.RegisterQuery(typeof(UserChartEntity), () =>
from uq in Database.Query<UserChartEntity>()
select new
{
Entity = uq,
uq.Query,
uq.EntityType,
uq.Id,
uq.DisplayName,
uq.ChartScript,
uq.GroupResults,
});
sb.Schema.EntityEvents<UserChartEntity>().Retrieved += ChartLogic_Retrieved;
new Graph<UserChartEntity>.Execute(UserChartOperation.Save)
{
AllowsNew = true,
Lite = false,
Execute = (uc, _) => { }
}.Register();
new Graph<UserChartEntity>.Delete(UserChartOperation.Delete)
{
Delete = (uc, _) => { uc.Delete(); }
}.Register();
UserCharts = sb.GlobalLazy(() => Database.Query<UserChartEntity>().ToDictionary(a => a.ToLite()),
new InvalidateWith(typeof(UserChartEntity)));
UserChartsByQuery = sb.GlobalLazy(() => UserCharts.Value.Values.Where(a => a.EntityType == null).GroupToDictionary(a => a.Query.ToQueryName(), a => a.ToLite()),
new InvalidateWith(typeof(UserChartEntity)));
UserChartsByType = sb.GlobalLazy(() => UserCharts.Value.Values.Where(a => a.EntityType != null).GroupToDictionary(a => TypeLogic.IdToType.GetOrThrow(a.EntityType.Id), a => a.ToLite()),
new InvalidateWith(typeof(UserChartEntity)));
}
}
示例4: Start
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
{
if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
{
sb.Include<SmtpConfigurationEntity>();
dqm.RegisterQuery(typeof(SmtpConfigurationEntity), () =>
from s in Database.Query<SmtpConfigurationEntity>()
select new
{
Entity = s,
s.Id,
s.DeliveryMethod,
s.Network.Host,
s.Network.Username,
s.PickupDirectoryLocation
});
SmtpConfigCache = sb.GlobalLazy(() => Database.Query<SmtpConfigurationEntity>().ToDictionary(a => a.ToLite()),
new InvalidateWith(typeof(SmtpConfigurationEntity)));
new Graph<SmtpConfigurationEntity>.Execute(SmtpConfigurationOperation.Save)
{
AllowsNew = true,
Lite = false,
Execute = (sc, _) => { },
}.Register();
}
}
示例5: Start
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
{
if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
{
sb.Include<DynamicValidationEntity>()
.WithSave(DynamicValidationOperation.Save)
.WithQuery(dqm, e => new
{
Entity = e,
e.Id,
e.Name,
e.EntityType,
e.PropertyRoute,
e.Eval,
});
DynamicValidations = sb.GlobalLazy(() =>
Database.Query<DynamicValidationEntity>()
.Select(dv => new DynamicValidationPair { Validation = dv, PropertyRoute = dv.PropertyRoute.ToPropertyRoute() })
.GroupToDictionary(a => a.PropertyRoute.PropertyInfo),
new InvalidateWith(typeof(DynamicValidationEntity)));
sb.Schema.Initializing += () => { initialized = true; };
Validator.GlobalValidation += DynamicValidation;
}
}
示例6: Start
internal static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
{
if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
{
sb.Include<ChartScriptEntity>();
dqm.RegisterQuery(typeof(ChartScriptEntity), () =>
from uq in Database.Query<ChartScriptEntity>()
select new
{
Entity = uq,
uq.Id,
uq.Name,
uq.GroupBy,
uq.Columns.Count,
uq.Icon,
});
Scripts = sb.GlobalLazy(() =>
{
var result = Database.Query<ChartScriptEntity>().ToDictionary(a => a.Name);
foreach (var e in result.Values)
if (e.Icon != null)
e.Icon.Retrieve();
return result;
}, new InvalidateWith(typeof(ChartScriptEntity)));
RegisterOperations();
}
}
示例7: Start
public static void Start(SchemaBuilder sb)
{
if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
{
sb.Include<PropertyRouteEntity>()
.WithUniqueIndex(p => new { p.Path, p.RootType });
sb.Schema.Synchronizing += SynchronizeProperties;
Properties = sb.GlobalLazy(() => Database.Query<PropertyRouteEntity>().AgGroupToDictionary(a => a.RootType, gr => gr.ToDictionary(a => a.Path)),
new InvalidateWith(typeof(PropertyRouteEntity)), Schema.Current.InvalidateMetadata);
}
}
示例8: Start
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
{
if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
{
sb.Include<DynamicViewEntity>()
.WithUniqueIndex(a => new { a.ViewName, a.EntityType })
.WithSave(DynamicViewOperation.Save)
.WithDelete(DynamicViewOperation.Delete)
.WithQuery(dqm, e => new
{
Entity = e,
e.Id,
e.ViewName,
e.EntityType,
});
new Graph<DynamicViewEntity>.Construct(DynamicViewOperation.Create)
{
Construct = (_) => new DynamicViewEntity(),
}.Register();
new Graph<DynamicViewEntity>.ConstructFrom<DynamicViewEntity>(DynamicViewOperation.Clone)
{
Construct = (e, _) => new DynamicViewEntity()
{
ViewName = "",
EntityType = e.EntityType,
ViewContent = e.ViewContent,
},
}.Register();
DynamicViews = sb.GlobalLazy(() =>
Database.Query<DynamicViewEntity>().GroupToDictionary(a => a.EntityType.ToType()),
new InvalidateWith(typeof(DynamicViewEntity)));
sb.Include<DynamicViewSelectorEntity>()
.WithSave(DynamicViewSelectorOperation.Save)
.WithDelete(DynamicViewSelectorOperation.Delete)
.WithQuery(dqm, e => new
{
Entity = e,
e.Id,
e.EntityType,
});
}
}
示例9: 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)));
}
}
示例10: Start
//.........这里部分代码省略.........
ExecuteTask.Register((ITaskEntity t) => { throw new NotImplementedException("SchedulerLogic.ExecuteTask not registered for {0}".FormatWith(t.GetType().Name)); });
SimpleTaskLogic.Start(sb, dqm);
sb.Include<ScheduledTaskEntity>();
sb.Include<ScheduledTaskLogEntity>();
dqm.RegisterQuery(typeof(HolidayCalendarEntity), () =>
from st in Database.Query<HolidayCalendarEntity>()
select new
{
Entity = st,
st.Id,
st.Name,
Holidays = st.Holidays.Count,
});
dqm.RegisterQuery(typeof(ScheduledTaskEntity), () =>
from st in Database.Query<ScheduledTaskEntity>()
select new
{
Entity = st,
st.Id,
st.Task,
st.Rule,
st.Suspended,
st.MachineName,
st.ApplicationName
});
dqm.RegisterQuery(typeof(ScheduledTaskLogEntity), () =>
from cte in Database.Query<ScheduledTaskLogEntity>()
select new
{
Entity = cte,
cte.Id,
cte.Task,
cte.ScheduledTask,
cte.StartTime,
cte.EndTime,
cte.ProductEntity,
cte.MachineName,
cte.User,
cte.Exception,
});
dqm.RegisterExpression((ITaskEntity ct) => ct.Executions(), () => TaskMessage.Executions.NiceToString());
dqm.RegisterExpression((ITaskEntity ct) => ct.LastExecution(), () => TaskMessage.LastExecution.NiceToString());
dqm.RegisterExpression((ScheduledTaskEntity ct) => ct.Executions(), () => TaskMessage.Executions.NiceToString());
new Graph<HolidayCalendarEntity>.Execute(HolidayCalendarOperation.Save)
{
AllowsNew = true,
Lite = false,
Execute = (c, _) => { },
}.Register();
new Graph<HolidayCalendarEntity>.Delete(HolidayCalendarOperation.Delete)
{
Delete = (c, _) => { c.Delete(); },
}.Register();
new Graph<ScheduledTaskEntity>.Execute(ScheduledTaskOperation.Save)
{
AllowsNew = true,
Lite = false,
Execute = (st, _) => { },
}.Register();
new Graph<ScheduledTaskEntity>.Delete(ScheduledTaskOperation.Delete)
{
Delete = (st, _) =>
{
st.Executions().UnsafeUpdate().Set(l => l.ScheduledTask, l => null).Execute();
var rule = st.Rule; st.Delete(); rule.Delete();
},
}.Register();
new Graph<IEntity>.ConstructFrom<ITaskEntity>(TaskOperation.ExecuteSync)
{
Construct = (task, _) => ExecuteSync(task, null, UserHolder.Current)?.Retrieve()
}.Register();
new Graph<ITaskEntity>.Execute(TaskOperation.ExecuteAsync)
{
Execute = (task, _) => ExecuteAsync(task, null, UserHolder.Current)
}.Register();
ScheduledTasksLazy = sb.GlobalLazy(() =>
Database.Query<ScheduledTaskEntity>().Where(a => !a.Suspended &&
(a.MachineName == ScheduledTaskEntity.None || a.MachineName == Environment.MachineName && a.ApplicationName == Schema.Current.ApplicationName)).ToList(),
new InvalidateWith(typeof(ScheduledTaskEntity)));
ScheduledTasksLazy.OnReset += ScheduledTasksLazy_OnReset;
ExceptionLogic.DeleteLogs += ExceptionLogic_DeleteLogs;
}
}
示例11: Start
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, string systemUserName, string anonymousUserName)
{
if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
{
SystemUserName = systemUserName;
AnonymousUserName = anonymousUserName;
CultureInfoLogic.AssertStarted(sb);
sb.Include<UserEntity>();
sb.Include<RoleEntity>()
.WithSave(RoleOperation.Save)
.WithDelete(RoleOperation.Delete)
.WithQuery(dqm, r => new
{
Entity = r,
r.Id,
r.Name,
});
sb.Include<LastAuthRulesImportEntity>();
roles = sb.GlobalLazy(CacheRoles, new InvalidateWith(typeof(RoleEntity)), AuthLogic.NotifyRulesChanged);
mergeStrategies = sb.GlobalLazy(() =>
{
var strategies = Database.Query<RoleEntity>().Select(r => KVP.Create(r.ToLite(), r.MergeStrategy)).ToDictionary();
var graph = roles.Value;
Dictionary<Lite<RoleEntity>, RoleData> result = new Dictionary<Lite<RoleEntity>, RoleData>();
foreach (var r in graph.CompilationOrder())
{
var strat = strategies.GetOrThrow(r);
var baseValues = graph.RelatedTo(r).Select(r2=>result[r2].DefaultAllowed);
result.Add(r, new RoleData
{
MergeStrategy = strat,
DefaultAllowed = strat == MergeStrategy.Union ? baseValues.Any(a => a) : baseValues.All(a => a)
});
}
return result;
}, new InvalidateWith(typeof(RoleEntity)), AuthLogic.NotifyRulesChanged);
sb.Schema.EntityEvents<RoleEntity>().Saving += Schema_Saving;
dqm.RegisterQuery(RoleQuery.RolesReferedBy, () =>
from r in Database.Query<RoleEntity>()
from rc in r.Roles
select new
{
Entity = r,
r.Id,
r.Name,
Refered = rc,
});
dqm.RegisterQuery(typeof(UserEntity), () =>
from e in Database.Query<UserEntity>()
select new
{
Entity = e,
e.Id,
e.UserName,
e.Email,
e.Role,
e.State,
});
UserGraph.Register();
}
}
示例12: StartSouthwindConfiguration
private static void StartSouthwindConfiguration(SchemaBuilder sb, DynamicQueryManager dqm)
{
sb.Include<ApplicationConfigurationEntity>();
Configuration = sb.GlobalLazy<ApplicationConfigurationEntity>(
() => Database.Query<ApplicationConfigurationEntity>().Single(a => a.Environment == Settings.Default.Environment),
new InvalidateWith(typeof(ApplicationConfigurationEntity)));
new Graph<ApplicationConfigurationEntity>.Execute(ApplicationConfigurationOperation.Save)
{
AllowsNew = true,
Lite = false,
Execute = (e, _) => { },
}.Register();
dqm.RegisterQuery(typeof(ApplicationConfigurationEntity), () =>
from s in Database.Query<ApplicationConfigurationEntity>()
select new
{
Entity = s,
s.Id,
s.Environment,
s.Email.SendEmails,
s.Email.OverrideEmailAddress,
s.Email.DefaultCulture,
s.Email.UrlLeft
});
}
示例13: Start
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
{
if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
{
sb.Include<WordTemplateEntity>();
SystemWordTemplateLogic.Start(sb, dqm);
SymbolLogic<WordTransformerSymbol>.Start(sb, () => Transformers.Keys.ToHashSet());
SymbolLogic<WordConverterSymbol>.Start(sb, () => Converters.Keys.ToHashSet());
dqm.RegisterQuery(typeof(WordTemplateEntity), ()=>
from e in Database.Query<WordTemplateEntity>()
select new
{
Entity = e,
e.Id,
e.Query,
e.Template.Entity.FileName
});
dqm.RegisterQuery(typeof(WordTransformerSymbol), () =>
from f in Database.Query<WordTransformerSymbol>()
select new
{
Entity = f,
f.Key
});
dqm.RegisterQuery(typeof(WordConverterSymbol), () =>
from f in Database.Query<WordConverterSymbol>()
select new
{
Entity = f,
f.Key
});
dqm.RegisterExpression((SystemWordTemplateEntity e) => e.WordTemplates(), () => typeof(WordTemplateEntity).NiceName());
new Graph<WordTemplateEntity>.Execute(WordTemplateOperation.Save)
{
AllowsNew = true,
Lite = false,
Execute = (e, _) => { }
}.Register();
new Graph<WordTemplateEntity>.Execute(WordTemplateOperation.CreateWordReport)
{
CanExecute = et =>
{
if (et.SystemWordTemplate != null && SystemWordTemplateLogic.RequiresExtraParameters(et.SystemWordTemplate))
return "SystemWordTemplate ({1}) requires extra parameters".FormatWith(et.SystemWordTemplate);
return null;
},
Execute = (et, args) =>
{
throw new InvalidOperationException("UI-only operation");
}
}.Register();
TemplatesByType = sb.GlobalLazy(() =>
{
var list = Database.Query<WordTemplateEntity>().Select(r => KVP.Create(r.Query, r.ToLite())).ToList();
return (from kvp in list
let imp = dqm.GetEntityImplementations(kvp.Key.ToQueryName())
where !imp.IsByAll
from t in imp.Types
group kvp.Value by t into g
select KVP.Create(g.Key.ToTypeEntity(), g.ToList())).ToDictionary();
}, new InvalidateWith(typeof(WordTemplateEntity)));
WordTemplatesLazy = sb.GlobalLazy(() => Database.Query<WordTemplateEntity>()
.ToDictionary(et => et.ToLite()), new InvalidateWith(typeof(WordTemplateEntity)));
Schema.Current.Synchronizing += Schema_Synchronize_Tokens;
Validator.PropertyValidator((WordTemplateEntity e) => e.Template).StaticPropertyValidation += ValidateTemplate;
}
}
示例14: Start
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
{
if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
{
sb.Include<ProductEntity>();
ActiveProducts = sb.GlobalLazy(() =>
Database.Query<ProductEntity>()
.Where(a => !a.Discontinued)
.Select(p => new { Category = p.Category.Entity, Product = p })
.GroupToDictionary(a => a.Category, a => a.Product),
new InvalidateWith(typeof(ProductEntity)));
dqm.RegisterQuery(typeof(ProductEntity), () =>
from p in Database.Query<ProductEntity>()
select new
{
Entity = p.ToLite(),
p.Id,
p.ProductName,
p.Supplier,
p.Category,
p.QuantityPerUnit,
p.UnitPrice,
p.UnitsInStock,
p.Discontinued
});
dqm.RegisterQuery(ProductQuery.Current, () =>
from p in Database.Query<ProductEntity>()
where !p.Discontinued
select new
{
Entity = p.ToLite(),
p.Id,
p.ProductName,
p.Supplier,
p.Category,
p.QuantityPerUnit,
p.UnitPrice,
p.UnitsInStock,
});
dqm.RegisterQuery(typeof(SupplierEntity), () =>
from s in Database.Query<SupplierEntity>()
select new
{
Entity = s.ToLite(),
s.Id,
s.CompanyName,
s.ContactName,
s.Phone,
s.Fax,
s.HomePage,
s.Address
});
dqm.RegisterQuery(typeof(CategoryEntity), () =>
from s in Database.Query<CategoryEntity>()
select new
{
Entity = s.ToLite(),
s.Id,
s.CategoryName,
s.Description,
s.Picture
});
new Graph<ProductEntity>.Execute(ProductOperation.Save)
{
AllowsNew = true,
Lite = false,
Execute = (e, _) => { }
}.Register();
new Graph<SupplierEntity>.Execute(SupplierOperation.Save)
{
AllowsNew = true,
Lite = false,
Execute = (e, _) => { }
}.Register();
new Graph<CategoryEntity>.Execute(CategoryOperation.Save)
{
AllowsNew = true,
Lite = false,
Execute = (e, _) => { }
}.Register();
}
}