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


C# EntityTypeConfiguration.HasMany方法代码示例

本文整理汇总了C#中EntityTypeConfiguration.HasMany方法的典型用法代码示例。如果您正苦于以下问题:C# EntityTypeConfiguration.HasMany方法的具体用法?C# EntityTypeConfiguration.HasMany怎么用?C# EntityTypeConfiguration.HasMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntityTypeConfiguration的用法示例。


在下文中一共展示了EntityTypeConfiguration.HasMany方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: buildCustomers

        protected void buildCustomers(EntityTypeConfiguration<Customer> customerEntity)
        {
            customerEntity
                .HasKey(x => x.customerID)
                .Property(x => x.name).IsRequired()
                .HasMaxLength(50);

            customerEntity
                .HasMany(x => x.orders)
                .WithRequired(x => x.customer)
                .HasForeignKey(x => x.customerID)
                .WillCascadeOnDelete();

            customerEntity
                .Property(x => x.timeStamp)
                .IsRequired();
        }
开发者ID:ziahamza,项目名称:Wirecraft,代码行数:17,代码来源:SqlDbContext.cs

示例2: configureEntity

        /// <summary>
        /// Configure LongShortUrl entityTypeConfiguration
        /// </summary>
        /// <param name="modelBuilder"></param>
        private static void configureEntity(EntityTypeConfiguration<LongShortUrl> entityTypeConfiguration)
        {
            entityTypeConfiguration.HasKey(e => e.Id);

            entityTypeConfiguration.Property(e => e.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            entityTypeConfiguration.Property(e => e.ShortUrlId).IsRequired().HasMaxLength(10);

            entityTypeConfiguration.Property(e => e.LongUrl).IsRequired().HasMaxLength(2000);

            entityTypeConfiguration.Property(e => e.CreatedDate).IsRequired();

            entityTypeConfiguration
                .HasMany(e => e.LongShortUrlUsers)
                .WithOptional()
                .HasForeignKey(e => e.LongShortUrlId)
                .WillCascadeOnDelete();

        }
开发者ID:aserplus,项目名称:itty-bitty-url,代码行数:23,代码来源:IttyBittyContext.cs

示例3: buildProducts

        protected void buildProducts(EntityTypeConfiguration<Product> productEntity)
        {
            productEntity
                .HasKey(x => x.productID)
                .Property(x => x.name)
                .HasMaxLength(50);

            productEntity
                .Property(x => x.price)
                .IsRequired();

            productEntity
                .Property(x => x.timeStamp)
                .IsRequired();

            productEntity
                .HasMany(x => x.files)
                .WithRequired(x => x.product)
                .HasForeignKey(x => x.productID)
                .WillCascadeOnDelete();
        }
开发者ID:ziahamza,项目名称:Wirecraft,代码行数:21,代码来源:SqlDbContext.cs

示例4: buildOrders

        protected void buildOrders(EntityTypeConfiguration<Order> orderEntity)
        {
            orderEntity
                .HasKey(x => x.orderID)
                .Property(x => x.orderDate)
                .IsRequired();

            orderEntity
                .Property(x => x.status)
                .IsRequired();

            orderEntity
                .Property(x => x.address)
                .IsRequired()
                .HasMaxLength(400);

            orderEntity
                .Property(x => x.timeStamp)
                .IsRequired();

            orderEntity
                .HasRequired(x => x.customer)
                .WithMany(x => x.orders);
            orderEntity
                .HasMany(x => x.products)
                .WithRequired(x => x.order)
                .WillCascadeOnDelete();
        }
开发者ID:ziahamza,项目名称:Wirecraft,代码行数:28,代码来源:SqlDbContext.cs

示例5: MapPerson

        protected override void MapPerson(EntityTypeConfiguration<Person> config)
        {
            base.MapPerson(config);

            config.HasMany(p => p.Kjøp).WithRequired(k => k.Person);
        }
开发者ID:geirsagberg,项目名称:Reference,代码行数:6,代码来源:EntityContext_Mappings.cs

示例6: Configurate

 public static void Configurate(EntityTypeConfiguration<Dish> config)
 {
     config.HasMany(e => e.Delicious).WithMany()
     .Map(m => m.ToTable("Delicious"));
 }
开发者ID:kissarat,项目名称:dandy,代码行数:5,代码来源:Dish.cs


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