本文整理汇总了C#中DatabaseSchemaReader.DataSchema.DatabaseTable.IsManyToManyTable方法的典型用法代码示例。如果您正苦于以下问题:C# DatabaseTable.IsManyToManyTable方法的具体用法?C# DatabaseTable.IsManyToManyTable怎么用?C# DatabaseTable.IsManyToManyTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseSchemaReader.DataSchema.DatabaseTable
的用法示例。
在下文中一共展示了DatabaseTable.IsManyToManyTable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FilterIneligible
private bool FilterIneligible(DatabaseTable table)
{
if (!IsCodeFirst()) return false;
if (table.IsManyToManyTable() && _codeWriterSettings.CodeTarget == CodeTarget.PocoEntityCodeFirst)
return true;
if (table.PrimaryKey == null)
return true;
if (table.Name.Equals("__MigrationHistory", StringComparison.OrdinalIgnoreCase)) //EF 6
return true;
if (table.Name.Equals("__EFMigrationsHistory", StringComparison.OrdinalIgnoreCase)) //EF Core1
return true;
if (table.Name.Equals("EdmMetadata", StringComparison.OrdinalIgnoreCase))
return true;
return false;
}
示例2: FilterIneligible
private bool FilterIneligible(DatabaseTable table)
{
if (!IsCodeFirst()) return false;
if (table.IsManyToManyTable())
return true;
if (table.PrimaryKey == null)
return true;
if (table.Name.Equals("__MigrationHistory", StringComparison.OrdinalIgnoreCase))
return true;
if (table.Name.Equals("EdmMetadata", StringComparison.OrdinalIgnoreCase))
return true;
return false;
}
示例3: WriteForeignKeyCollection
private void WriteForeignKeyCollection(DatabaseTable foreignKeyChild)
{
if (foreignKeyChild.IsManyToManyTable())
{
WriteManyToManyForeignKeyCollection(foreignKeyChild);
return;
}
var foreignKeyTable = foreignKeyChild.Name;
var childClass = foreignKeyChild.NetName;
var foreignKey = foreignKeyChild.ForeignKeys.FirstOrDefault(fk => fk.RefersToTable == _table.Name);
if (foreignKey == null) return; //corruption in our database
//we won't deal with composite keys
if (_table.IsSharedPrimaryKey(foreignKeyChild))
{
_cb.AppendFormat("//shared primary key to {0} ({1})", foreignKeyTable, childClass);
_cb.AppendFormat("HasOptional(x => x.{0});", childClass);
return;
}
var fks = _table.InverseForeignKeys(foreignKeyChild);
foreach (var fk in fks)
{
_cb.AppendFormat("//Foreign key to {0} ({1})", foreignKeyTable, childClass);
var propertyName = _codeWriterSettings.Namer.ForeignKeyCollectionName(_table.Name, foreignKeyChild, fk);
//specify the opposite direction? Probably not needed
_cb.AppendFormat("HasMany(x => x.{0});", propertyName);
}
}
示例4: WriteForeignKeyCollection
private void WriteForeignKeyCollection(DatabaseTable foreignKeyChild)
{
if (foreignKeyChild.IsManyToManyTable() && _codeWriterSettings.CodeTarget == CodeTarget.PocoEntityCodeFirst)
{
WriteManyToManyForeignKeyCollection(foreignKeyChild);
return;
}
var foreignKeyTable = foreignKeyChild.Name;
var childClass = foreignKeyChild.NetName;
var foreignKey = foreignKeyChild.ForeignKeys.FirstOrDefault(fk => fk.RefersToTable == _table.Name);
if (foreignKey == null) return; //corruption in our database
//we won't deal with composite keys
if (_table.IsSharedPrimaryKey(foreignKeyChild))
{
_cb.AppendFormat("//shared primary key to {0} ({1})", foreignKeyTable, childClass);
if (_codeWriterSettings.CodeTarget == CodeTarget.PocoEntityCodeFirst)
{
_cb.AppendFormat(Builder + "HasOptional(x => x.{0});", childClass);
}
else
{
_cb.AppendFormat(Builder + "HasOne(x => x.{0}).WithOne();", childClass);
}
return;
}
//the foreign keys that point at this table from the other table
var fks = _table.InverseForeignKeys(foreignKeyChild);
foreach (var fk in fks)
{
_cb.AppendFormat("//Foreign key to {0} ({1})", foreignKeyTable, childClass);
var propertyName = _codeWriterSettings.Namer.ForeignKeyCollectionName(_table.Name, foreignKeyChild, fk);
if (_codeWriterSettings.CodeTarget == CodeTarget.PocoEntityCodeFirst)
{
//specify the opposite direction? Probably not needed
_cb.AppendFormat("HasMany(x => x.{0});", propertyName);
}
else
{
//EF Core v1 - inverse direction is required in Core
var dependentPropertyName = _codeWriterSettings.Namer.ForeignKeyName(foreignKeyChild, fk);
_cb.AppendFormat("b.HasMany(x => x.{0}).WithOne(d => d.{1});", propertyName, dependentPropertyName);
}
}
}