本文整理汇总了C#中System.Reference.SetReferenceEnd2CollectionCascade方法的典型用法代码示例。如果您正苦于以下问题:C# Reference.SetReferenceEnd2CollectionCascade方法的具体用法?C# Reference.SetReferenceEnd2CollectionCascade怎么用?C# Reference.SetReferenceEnd2CollectionCascade使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reference
的用法示例。
在下文中一共展示了Reference.SetReferenceEnd2CollectionCascade方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessOtherEndOfReference
private void ProcessOtherEndOfReference(AssociationInformation info, Entity toEntity, Reference reference)
{
var potentialOtherEnds =
associationInformation.Where(inf => inf.ThisEntityName == info.OtherEntityName
&& inf.OtherEntityName == info.ThisEntityName);
AssociationInformation otherEndInfo = null;
if (potentialOtherEnds.Count() == 1)
otherEndInfo = potentialOtherEnds.FirstOrDefault();
else if (potentialOtherEnds.Count() > 1)
{
foreach (var pot in potentialOtherEnds)
{
if (info.ForeignKeyColumnNames.Count == pot.ForeignKeyColumnNames.Count)
{
bool found = true;
for (int i = 0; i < info.ForeignKeyColumnNames.Count; i++)
{
if (pot.ForeignKeyColumnNames[i] != info.ForeignKeyColumnNames[i])
{
found = false;
break;
}
}
if (found)
{
otherEndInfo = pot;
break;
}
}
}
//log.Error("While processing references, ");
}
reference.Entity2 = toEntity;
if (info.ForeignKeyColumnNames.Count == 0 && otherEndInfo != null)
{
info.ForeignKeyColumnNames = otherEndInfo.ForeignKeyColumnNames;
info.ForeignKeyBelongsToThisTable = false;
}
if (otherEndInfo == null)
{
reference.End2Enabled = false;
Cardinality cardinality;
if (info.AssociationTableName != null && !string.IsNullOrEmpty(info.AssociationTableName.TableName))
cardinality = Cardinality.Many;
else if (info.HasUniqueConstraint)
cardinality = Cardinality.One;
else
cardinality = Cardinality.Many;
reference.Cardinality2 = cardinality;
}
else
{
reference.End2Enabled = true;
reference.End2Name = otherEndInfo.PropertyName;
reference.Cardinality2 = otherEndInfo.Cardinality;
reference.SetEnd2AssociationType(otherEndInfo.AssociationType);
reference.SetEnd2IndexColumnName(otherEndInfo.IndexColumn);
reference.SetEnd2SqlWhereClause(otherEndInfo.WhereClause);
reference.SetReferenceEnd2FetchMode(otherEndInfo.FetchMode);
reference.SetReferenceEnd2CollectionFetchMode(otherEndInfo.CollectionFetchMode);
reference.SetReferenceEnd2Insert(otherEndInfo.Insert);
reference.SetReferenceEnd2Update(otherEndInfo.Update);
reference.SetReferenceEnd2Inverse(otherEndInfo.Inverse);
reference.SetReferenceEnd2Cascade(otherEndInfo.Cascade);
reference.SetReferenceEnd2CollectionCascade(otherEndInfo.CollectionCascade);
reference.SetReferenceEnd2Lazy(otherEndInfo.CollectionLazy);
reference.SetReferenceEnd2OrderByIsAsc(otherEndInfo.OrderByIsAsc);
if (!string.IsNullOrWhiteSpace(otherEndInfo.OrderByColumnName))
{
var orderByProp = toEntity.Properties.SingleOrDefault(p => p.MappedColumn() != null && p.MappedColumn().Name.Equals(otherEndInfo.OrderByColumnName, StringComparison.InvariantCultureIgnoreCase));
if (orderByProp != null)
reference.SetReferenceEnd2OrderByProperty(orderByProp.Name);
}
//reference.SetReferenceEnd2OrderByProperty(otherEndInfo.OrderByColumnName);
associationInformation.Remove(otherEndInfo);
}
}