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


C# EntityTypeConfiguration.Property方法代码示例

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


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

示例1: MapApiDataSource

 /// <summary>Defines the mapping information for the entity 'ApiDataSource'</summary>
 /// <param name="config">The configuration to modify.</param>
 protected virtual void MapApiDataSource(EntityTypeConfiguration<ApiDataSource> config)
 {
     config.ToTable("ApiDataSource");
     config.HasKey(t => t.Id);
     config.Property(t => t.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
     config.Property(t => t.SourceName).HasMaxLength(50).IsRequired();
     config.Property(t => t.SourceBaseUrl).HasMaxLength(200);
 }
开发者ID:justinrobinson,项目名称:ODataTest,代码行数:10,代码来源:SqlExpressNovemberModelBuilder.cs

示例2: HandlerInfoConfiguration

        private EntityTypeConfiguration<HandlerRecord> HandlerInfoConfiguration()
        {
            var config = new EntityTypeConfiguration<HandlerRecord>();

            config.HasKey(handler => new { handler.MessageId, handler.MessageTypeCode, handler.HandlerTypeCode });
            config.Property(handler => handler.MessageId).IsRequired().HasColumnType("char").HasMaxLength(36);
            config.Property(handler => handler.MessageTypeCode).IsRequired().HasColumnType("int");
            config.Property(handler => handler.HandlerTypeCode).HasColumnType("int");
            config.Property(handler => handler.Timestamp).HasColumnName("OnCreated").HasColumnType("datetime");

            config.ToTable("thinknet_handlers");

            return config;
        }
开发者ID:y2ket,项目名称:thinknet,代码行数:14,代码来源:ThinkNetDbContext.cs

示例3: SnapshotConfiguration

        private EntityTypeConfiguration<Snapshot> SnapshotConfiguration()
        {
            var config = new EntityTypeConfiguration<Snapshot>();

            config.HasKey(snapshot => new { snapshot.AggregateRootId, snapshot.AggregateRootTypeCode });
            config.Property(snapshot => snapshot.AggregateRootId).IsRequired().HasColumnType("char").HasMaxLength(36);
            config.Property(snapshot => snapshot.AggregateRootTypeCode).IsRequired().HasColumnType("int");
            config.Property(snapshot => snapshot.Version).HasColumnType("int");
            config.Property(snapshot => snapshot.Data).HasColumnType("varchar");
            config.Property(snapshot => snapshot.Timestamp).HasColumnName("OnCreated").HasColumnType("datetime");

            config.ToTable("thinknet_snapshots");

            return config;
        }
开发者ID:y2ket,项目名称:thinknet,代码行数:15,代码来源:ThinkNetDbContext.cs

示例4: Configure_should_throw_when_property_not_found

        public void Configure_should_throw_when_property_not_found()
        {
            var entityType = new EdmEntityType { Name = "E" };
            var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
            var mockPropertyConfiguration = new Mock<PrimitivePropertyConfiguration>();
            entityTypeConfiguration.Property(new PropertyPath(new MockPropertyInfo()), () => mockPropertyConfiguration.Object);

            Assert.Equal(Strings.PropertyNotFound(("P"), "E"), Assert.Throws<InvalidOperationException>(() => entityTypeConfiguration.Configure(entityType, new EdmModel())).Message);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:9,代码来源:EntityTypeConfigurationTests.cs

示例5: 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

示例6: Define

        internal static void Define(EntityTypeConfiguration<Domain.Transaction> config)
        {
            config.HasOptional(p => p.CreditedUser)
                .WithMany(r => r.Credits)
                .HasForeignKey(fk => fk.CreditedUserId);

            config.HasOptional(p => p.DebitedUser)
                .WithMany(r => r.Debits)
                .HasForeignKey(fk => fk.DebitedUserId);

            config.Property(p => p.Amount).HasPrecision(19, 4);
        }
开发者ID:RichardAllanBrown,项目名称:OctoBotSharp,代码行数:12,代码来源:TransactionMap.cs

示例7: buildBlobs

        protected void buildBlobs(EntityTypeConfiguration<Blob> blobEntity)
        {
            blobEntity
                .HasKey(x => x.blobID);

            blobEntity
                .Property(x => x.data)
                .IsRequired();

            blobEntity
                .Property(x => x.name)
                .IsRequired()
                .HasMaxLength(500);

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

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

示例8: MapMovieNotFound

 /// <summary>Defines the mapping information for the entity 'MovieNotFound'</summary>
 /// <param name="config">The configuration to modify.</param>
 protected virtual void MapMovieNotFound(EntityTypeConfiguration<MovieNotFound> config)
 {
     config.ToTable("MovieNotFound");
     config.HasKey(t => new { t.ItemId, t.ItemSource });
     config.Property(t => t.ItemId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
     config.Property(t => t.ItemSource).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
     config.Property(t => t.RowId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).IsRequired();
     config.Property(t => t.ItemSearchTitle).HasMaxLength(100);
     config.Property(t => t.ItemSearchYear);
     config.Property(t => t.AddedOn);
     config.Property(t => t.ChangedOn);
 }
开发者ID:justinrobinson,项目名称:ODataTest,代码行数:14,代码来源:SqlExpressNovemberModelBuilder.cs

示例9: Configure_should_configure_properties

        public void Configure_should_configure_properties()
        {
            var entityType = new EdmEntityType { Name = "E" };
            var property = entityType.AddPrimitiveProperty("P");
            property.PropertyType.EdmType = EdmPrimitiveType.Int32;
            var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
            var mockPropertyConfiguration = new Mock<PrimitivePropertyConfiguration>();
            var mockPropertyInfo = new MockPropertyInfo();
            property.SetClrPropertyInfo(mockPropertyInfo);
            entityTypeConfiguration.Property(new PropertyPath(mockPropertyInfo), () => mockPropertyConfiguration.Object);

            entityTypeConfiguration.Configure(entityType, new EdmModel());

            mockPropertyConfiguration.Verify(p => p.Configure(property));
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:15,代码来源:EntityTypeConfigurationTests.cs

示例10: Configure_should_configure_properties

        public void Configure_should_configure_properties()
        {
            var entityType = new EntityType
                                 {
                                     Name = "E"
                                 };
            var property1 = EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            entityType.AddMember(property1);
            var property = property1;
            var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
            var mockPropertyConfiguration = new Mock<PrimitivePropertyConfiguration>();
            var mockPropertyInfo = new MockPropertyInfo();
            property.SetClrPropertyInfo(mockPropertyInfo);
            entityTypeConfiguration.Property(new PropertyPath(mockPropertyInfo), () => mockPropertyConfiguration.Object);

            entityTypeConfiguration.Configure(entityType, new EdmModel());

            mockPropertyConfiguration.Verify(p => p.Configure(property));
        }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:20,代码来源:EntityTypeConfigurationTests.cs

示例11: EventDataConfiguration

        private EntityTypeConfiguration<Event> EventDataConfiguration()
        {
            var config = new EntityTypeConfiguration<Event>();

            config.HasKey(@event => new { @event.AggregateRootId, @event.AggregateRootTypeCode, @event.Version });
            config.Property(@event => @event.AggregateRootId).IsRequired().HasColumnType("char").HasMaxLength(36);
            config.Property(@event => @event.AggregateRootTypeCode).IsRequired().HasColumnType("int");
            config.Property(@event => @event.Version).HasColumnType("int");
            config.Property(@event => @event.CorrelationId).HasColumnType("char").HasMaxLength(36);
            config.Property(@event => @event.Payload).HasColumnType("varchar");
            config.Property(@event => @event.Timestamp).HasColumnName("OnCreated").HasColumnType("datetime");

            config.ToTable("thinknet_events");

            return config;
        }
开发者ID:y2ket,项目名称:thinknet,代码行数:16,代码来源:ThinkNetDbContext.cs

示例12: 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

示例13: MapMovieCreditResult

 /// <summary>Defines the mapping information for the entity 'MovieCreditResult'</summary>
 /// <param name="config">The configuration to modify.</param>
 protected virtual void MapMovieCreditResult(EntityTypeConfiguration<MovieCreditResult> config)
 {
     config.ToTable("MovieCreditResult");
     config.HasKey(t => new { t.ItemId, t.RowId });
     config.Property(t => t.ItemId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
     config.Property(t => t.RowId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
     config.Property(t => t.ItemSearchTitle).HasMaxLength(100);
     config.Property(t => t.ApiUrl).HasMaxLength(200);
     config.Property(t => t.ResultNum);
     config.Property(t => t.Name).HasMaxLength(100);
     config.Property(t => t.Order);
     config.Property(t => t.CastId).HasColumnName("Cast_Id");
     config.Property(t => t.Character).HasMaxLength(100);
     config.Property(t => t.CreditId).HasColumnName("Credit_Id").HasMaxLength(50);
     config.Property(t => t.TmdId);
     config.Property(t => t.ProfilePath).HasColumnName("Profile_Path").HasMaxLength(200);
     config.Property(t => t.AddedOn);
     config.Property(t => t.ChangedOn);
 }
开发者ID:justinrobinson,项目名称:ODataTest,代码行数:21,代码来源:SqlExpressNovemberModelBuilder.cs

示例14: Configure_should_configure_and_order_keys_when_keys_and_order_specified

        public void Configure_should_configure_and_order_keys_when_keys_and_order_specified()
        {
            var entityType = new EdmEntityType { Name = "E" };
            entityType.AddPrimitiveProperty("P2").PropertyType.EdmType = EdmPrimitiveType.Int32;
            entityType.AddPrimitiveProperty("P1").PropertyType.EdmType = EdmPrimitiveType.Int32;

            var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
            var mockPropertyInfo2 = new MockPropertyInfo(typeof(int), "P2");
            entityTypeConfiguration.Key(mockPropertyInfo2);
            entityTypeConfiguration.Property(new PropertyPath(mockPropertyInfo2)).ColumnOrder = 1;
            entityType.GetDeclaredPrimitiveProperty("P2").SetClrPropertyInfo(mockPropertyInfo2);
            var mockPropertyInfo1 = new MockPropertyInfo(typeof(int), "P1");
            entityTypeConfiguration.Key(mockPropertyInfo1);
            entityTypeConfiguration.Property(new PropertyPath(mockPropertyInfo1)).ColumnOrder = 0;
            entityType.GetDeclaredPrimitiveProperty("P1").SetClrPropertyInfo(mockPropertyInfo1);

            entityTypeConfiguration.Configure(entityType, new EdmModel());

            Assert.Equal(2, entityType.DeclaredKeyProperties.Count);
            Assert.Equal("P1", entityType.DeclaredKeyProperties.First().Name);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:21,代码来源:EntityTypeConfigurationTests.cs

示例15: MapVare

 /// <summary>
 /// Maps the type <see cref="Reference.Domain.Entities.Vare"/> to the table defined by <seealso cref="TableAttribute.Name"/>.
 /// </summary>
 protected virtual void MapVare(EntityTypeConfiguration<Vare> config)
 {
     config.ToTable("Vare");
     config.Property(v=>v.Version).IsConcurrencyToken().IsRowVersion();
     config.HasKey(e=>e.Id);
 }
开发者ID:geirsagberg,项目名称:Reference,代码行数:9,代码来源:EntityContextBase.cs


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