本文整理汇总了C#中ObjectClass.GetRelationEndsWithLocalStorage方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectClass.GetRelationEndsWithLocalStorage方法的具体用法?C# ObjectClass.GetRelationEndsWithLocalStorage怎么用?C# ObjectClass.GetRelationEndsWithLocalStorage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectClass
的用法示例。
在下文中一共展示了ObjectClass.GetRelationEndsWithLocalStorage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoCreateUpdateRightsTrigger
public void DoCreateUpdateRightsTrigger(ObjectClass objClass)
{
var updateRightsTriggerName = Construct.SecurityRulesUpdateRightsTriggerName(objClass);
var tblName = db.GetTableName(objClass.Module.SchemaName, objClass.TableName);
if (db.CheckTriggerExists(tblName, updateRightsTriggerName))
db.DropTrigger(tblName, updateRightsTriggerName);
var tblList = new List<RightsTrigger>();
tblList.Add(new RightsTrigger()
{
TblName = db.GetTableName(objClass.Module.SchemaName, objClass.TableName),
TblNameRights = db.GetTableName(objClass.Module.SchemaName, Construct.SecurityRulesTableName(objClass)),
ViewUnmaterializedName = db.GetTableName(objClass.Module.SchemaName, Construct.SecurityRulesRightsViewUnmaterializedName(objClass))
});
// Get all ObjectClasses that depends on current object class
var list = schema.GetQuery<ObjectClass>()
.Where(o => o.AccessControlList.OfType<RoleMembership>()
.Where(rm => rm.Relations
.Where(r => r.A.Type == objClass || r.B.Type == objClass).Count() > 0).Count() > 0)
.Distinct().ToList().Where(o => o.NeedsRightsTable() && o != objClass);
foreach (var dep in list)
{
Log.DebugFormat(" Additional update Table: {0}", dep.TableName);
foreach (var ac in dep.AccessControlList.OfType<RoleMembership>())
{
var rel = ac.Relations.FirstOrDefault(r => r.A.Type == objClass || r.B.Type == objClass);
if (rel != null)
{
var rt = new RightsTrigger()
{
TblName = db.GetTableName(dep.Module.SchemaName, dep.TableName),
TblNameRights = db.GetTableName(dep.Module.SchemaName, Construct.SecurityRulesTableName(dep)),
ViewUnmaterializedName = db.GetTableName(dep.Module.SchemaName, Construct.SecurityRulesRightsViewUnmaterializedName(dep)),
};
try
{
rt.Relations.AddRange(SchemaManager.CreateJoinList(db, dep, ac.Relations, rel));
}
catch (Zetbox.Server.SchemaManagement.SchemaManager.JoinListException ex)
{
Log.Warn("Unable to create UpdateRightsTrigger on " + objClass, ex);
return;
}
tblList.Add(rt);
}
}
}
// do not check fk_ChangedBy since it always changes, even when only recalculations were done.
// ACLs MUST never use ChangedBy information
var fkCols = objClass.GetRelationEndsWithLocalStorage()
.Where(r => !(r.Type.ImplementsIChangedBy() && r.Navigator != null && r.Navigator.Name =="ChangedBy"))
.Select(r => Construct.ForeignKeyColumnName(r.GetParent().GetOtherEnd(r)))
.ToList();
db.CreateUpdateRightsTrigger(updateRightsTriggerName, tblName, tblList, fkCols);
}