本文整理汇总了C#中DatabaseSchemaReader.DataSchema.DatabaseTable.ManyToManyTraversal方法的典型用法代码示例。如果您正苦于以下问题:C# DatabaseTable.ManyToManyTraversal方法的具体用法?C# DatabaseTable.ManyToManyTraversal怎么用?C# DatabaseTable.ManyToManyTraversal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseSchemaReader.DataSchema.DatabaseTable
的用法示例。
在下文中一共展示了DatabaseTable.ManyToManyTraversal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteManyToManyInitialize
private void WriteManyToManyInitialize(DatabaseTable foreignKey)
{
//look over the junction table to find the other many-to-many end
var target = foreignKey.ManyToManyTraversal(_table);
if (target == null)
{
return;
}
var propertyName = _codeWriterSettings.Namer.NameCollection(target.NetName);
var dataType = "List<" + target.NetName + ">";
_cb.AppendLine(propertyName + " = new " + dataType + "();");
}
示例2: WriteManyToManyForeignKeyCollection
private void WriteManyToManyForeignKeyCollection(DatabaseTable foreignKeyChild)
{
var otherEnd = foreignKeyChild.ManyToManyTraversal(_table);
_cb.AppendLine("// Many to many foreign key to " + otherEnd.Name);
var childClass = otherEnd.NetName;
var propertyName = _codeWriterSettings.Namer.NameCollection(childClass);
var reverseName = _codeWriterSettings.Namer.NameCollection(_table.NetName);
var sb = new StringBuilder();
sb.AppendFormat(CultureInfo.InvariantCulture, "HasMany(x => x.{0})", propertyName);
sb.AppendFormat(CultureInfo.InvariantCulture, ".WithMany(z => z.{0})", reverseName);
_cb.AppendLine(sb.ToString());
using (_cb.BeginBrace(".Map(map => "))
{
_cb.AppendLine("map.ToTable(\"" + foreignKeyChild.Name + "\");");
//left key = HasMany side
var cols = foreignKeyChild.ForeignKeys
.First(x => x.RefersToTable == _table.Name)
.Columns.Select(x => '"' + x + '"')
.ToArray();
var leftColumns = string.Join(", ", cols);
_cb.AppendLine("map.MapLeftKey(" + leftColumns + ");");
//right key = WithMany side
cols = foreignKeyChild.ForeignKeys
.First(x => x.RefersToTable == otherEnd.Name)
.Columns.Select(x => '"' + x + '"')
.ToArray();
var rightColumns = string.Join(", ", cols);
_cb.AppendLine("map.MapRightKey(" + rightColumns + ");");
}
_cb.AppendLine(");");
}
示例3: WriteManyToManyCollection
private void WriteManyToManyCollection(DatabaseTable foreignKey)
{
//look over the junction table to find the other many-to-many end
var target = foreignKey.ManyToManyTraversal(_table);
if (target == null)
{
Debug.WriteLine("Can't navigate the many to many relationship for " + _table.Name + " to " + foreignKey.Name);
return;
}
var propertyName = _codeWriterSettings.Namer.NameCollection(target.NetName);
var dataType = "ICollection<" + target.NetName + ">";
_cb.AppendAutomaticCollectionProperty(dataType, propertyName, IsNHibernate());
}