当前位置: 首页>>代码示例>>C#>>正文


C# DatabaseTable.IsManyToManyTable方法代码示例

本文整理汇总了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;
 }
开发者ID:shiningrise,项目名称:dbschemareader,代码行数:15,代码来源:CodeWriter.cs

示例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;
 }
开发者ID:Petran15,项目名称:dbschemareader,代码行数:13,代码来源:CodeWriter.cs

示例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);

            }
        }
开发者ID:Petran15,项目名称:dbschemareader,代码行数:30,代码来源:CodeFirstMappingWriter.cs

示例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);
                }
            }
        }
开发者ID:shiningrise,项目名称:dbschemareader,代码行数:47,代码来源:CodeFirstMappingWriter.cs


注:本文中的DatabaseSchemaReader.DataSchema.DatabaseTable.IsManyToManyTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。