Exemplo n.º 1
0
        protected sealed override void SetEntitySpecificProperties()
        {
            ContractUtility.Requires <ArgumentNullException>(CreatedByColumnName.IsNotNullOrWhiteSpace(), "CreatedByColumnName cannot be null or empty.");
            ContractUtility.Requires <ArgumentNullException>(CreationDateColumnName.IsNotNullOrWhiteSpace(), "CreationDateColumnName cannot be null or empty.");
            ContractUtility.Requires <ArgumentNullException>(LastUpdatedByColumnName.IsNotNullOrWhiteSpace(), "LastUpdatedByColumnName Name cannot be null or empty.");
            ContractUtility.Requires <ArgumentNullException>(LastUpdationDateColumnName.IsNotNullOrWhiteSpace(), "LastUpdationDateColumnName Name cannot be null or empty.");

            SetSpecificPropertiesForEntity();

            ExtendCreatedByPropertyWithOtherConfigurations(Property(p => p.T1Data.CreatedBy).HasColumnName(CreatedByColumnName));
            ExtendCreationDatePropertyWithOtherConfigurations(Property(p => p.T1Data.CreatedOn).HasColumnName(CreationDateColumnName));
            ExtendLastUpdatedByPropertyWithOtherConfigurations(Property(p => p.T1Data.LastUpdatedBy).HasColumnName(LastUpdatedByColumnName));
            ExtendLastUpdatedDatePropertyWithOtherConfigurations(Property(p => p.T1Data.LastUpdateOn).HasColumnName(LastUpdationDateColumnName));
        }
        public override void Configure(EntityTypeBuilder <TEntity> builder)
        {
            ContractUtility.Requires <ArgumentNullException>(CreatedByColumnName.IsNotNullOrWhiteSpace(), "CreatedByColumnName cannot be null or empty.");
            ContractUtility.Requires <ArgumentNullException>(CreationDateColumnName.IsNotNullOrWhiteSpace(), "CreationDateColumnName cannot be null or empty.");
            ContractUtility.Requires <ArgumentNullException>(LastUpdatedByColumnName.IsNotNullOrWhiteSpace(), "LastUpdatedByColumnName Name cannot be null or empty.");
            ContractUtility.Requires <ArgumentNullException>(LastUpdationDateColumnName.IsNotNullOrWhiteSpace(), "LastUpdationDateColumnName Name cannot be null or empty.");

            base.Configure(builder);

            ExtendCreatedByPropertyWithOtherConfigurations(builder.OwnsOne(p => p.T1Data).Property(p => p.CreatedBy).HasColumnName(CreatedByColumnName));
            var createdOnProperty = builder.OwnsOne(p => p.T1Data).Property(p => p.CreatedOn).HasColumnName(CreationDateColumnName);

            createdOnProperty.ValueGeneratedOnAdd();
            ExtendCreationDatePropertyWithOtherConfigurations(createdOnProperty);
            ExtendLastUpdatedByPropertyWithOtherConfigurations(builder.OwnsOne(p => p.T1Data).Property(p => p.LastUpdatedBy).HasColumnName(LastUpdatedByColumnName));
            var lastUpdatedOnProperty = builder.OwnsOne(p => p.T1Data).Property(p => p.LastUpdateOn).HasColumnName(LastUpdationDateColumnName);

            lastUpdatedOnProperty.ValueGeneratedOnUpdate();
            ExtendLastUpdatedDatePropertyWithOtherConfigurations(lastUpdatedOnProperty);
        }