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


C# DatabaseTable.ManyToManyTraversal方法代码示例

本文整理汇总了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 + "();");
 }
开发者ID:Petran15,项目名称:dbschemareader,代码行数:12,代码来源:ClassWriter.cs

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

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

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

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


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