public DynamicPropertyInfo(String name, Type type, bool isNullable, DatabaseGeneratedOption databaseGeneratedOption)
 {
     IsNullable = isNullable;
     Name       = name;
     Type       = type;
     DatabaseGeneratedOption = databaseGeneratedOption;
 }
        public void UsesSpecifiedDatabaseGeneratedOption(DatabaseGeneratedOption databaseGeneratedOption)
        {
            var kpi = new ColumnPropertyInfo(typeof(Bar).GetProperty("Id") !, databaseGeneratedOption);

            Assert.Equal(databaseGeneratedOption, kpi.GeneratedOption);
            Assert.Equal(typeof(Bar).GetProperty("Id"), kpi.Property);
        }
        /// <summary>
        ///     Configures how values for the property are generated by the database.
        /// </summary>
        /// <param name="databaseGeneratedOption"> The pattern used to generate values for the property in the database. Setting 'null' will remove the database generated pattern facet from the property. Setting 'null' will cause the same runtime behavior as specifying 'None'. </param>
        /// <returns> The same DateTimePropertyConfiguration instance so that multiple calls can be chained. </returns>
        public new DateTimePropertyConfiguration HasDatabaseGeneratedOption(
            DatabaseGeneratedOption? databaseGeneratedOption)
        {
            base.HasDatabaseGeneratedOption(databaseGeneratedOption);

            return this;
        }
Example #4
0
 protected BaseEntityMapping(DatabaseGeneratedOption databaseGeneratedOption = DatabaseGeneratedOption.Identity)
 {
     this.HasKey(x => x.Id)
     .Property(t => t.Id)
     .HasDatabaseGeneratedOption(databaseGeneratedOption);
     this.Property(x => x.Version).IsRowVersion();
 }
        /// <summary>
        /// Indicates that the property is mapped to a database generated field.
        /// This does not cover default values generated by the database (please use <see cref="ExcludeFromInserts"/> and <see cref="RefreshOnInserts"/> for this scenario).
        /// </summary>
        public PropertyMapping SetDatabaseGenerated(DatabaseGeneratedOption option)
        {
            switch (option)
            {
            case DatabaseGeneratedOption.Computed:
                this.IsExcludedFromInserts = true;
                this.IsExcludedFromUpdates = true;
                this.IsRefreshedOnInserts  = true;
                this.IsRefreshedOnUpdates  = true;
                break;

            case DatabaseGeneratedOption.Identity:
                this.IsExcludedFromInserts = true;
                this.IsExcludedFromUpdates = true;
                this.IsRefreshedOnInserts  = true;
                this.IsRefreshedOnUpdates  = false;
                break;

            case DatabaseGeneratedOption.None:
                this.IsExcludedFromInserts = false;
                this.IsExcludedFromUpdates = false;
                this.IsRefreshedOnInserts  = false;
                this.IsRefreshedOnUpdates  = false;
                break;

            default:
                throw new NotSupportedException($"Option {option} is not supported.");
            }
            return(this);
        }
Example #6
0
        public DefinitionItemMap()
        {
            DatabaseGeneratedOption option = Config.Instance.GeneratedOption;
            bool unicode = Config.Instance.UnicodeString;

            // Primary Key
            HasKey(t => new { t.Id });

            // Properties
            Property(p => p.Id).HasDatabaseGeneratedOption(option);
            Property(p => p.DeploymentId).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute("IX_ITEM_DEFINITION_DEFINITION_ID")));
            Property(p => p.DefinitionItemId).IsRequired().HasMaxLength(255).IsUnicode(unicode).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute("IX_ITEM_DEFINITION_ID")));
            //Property(p => p.Incoming).HasMaxLength(255).IsUnicode(unicode);
            //Property(p => p.Outgoing).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.StructureRef).HasMaxLength(255).IsUnicode(unicode);
            //Property(p => p.SourceRef).HasMaxLength(255).IsUnicode(unicode);
            //Property(p => p.TargetRef).HasMaxLength(255).IsUnicode(unicode);
            //Property(p => p.CompletionQuantity).HasMaxLength(255).IsUnicode(unicode);
            //Property(p => p.StartQuantity).HasMaxLength(255).IsUnicode(unicode);
            //Property(p => p.Users).IsUnicode(unicode);
            //Property(p => p.Roles).IsUnicode(unicode);
            //Ignore(t => t.UserCandidates);
            //Ignore(t => t.RoleCandidates);

            // Table & Column Mappings
            ToTable(Config.Instance.Tables.DefinitionItem);
            MapToStoredProcedures();
        }
Example #7
0
        public ProcessTaskMap()
        {
            DatabaseGeneratedOption option = Config.Instance.GeneratedOption;
            bool unicode = Config.Instance.UnicodeString;

            // Primary Key
            HasKey(t => new { t.Id });

            // Properties
            Property(p => p.Id).HasDatabaseGeneratedOption(option);
            //Property(p => p.Name).HasMaxLength(255).IsUnicode(unicode).AddColumnIndex("IX_TASK_NAME", 0);
            Property(p => p.ProcessInstanceId).AddColumnIndex("IX_TASK_PROCESS_INSTANCE_ID", 0).AddColumnIndex("IX_TASK_PROCESS_INSTANCE_ID_FLOW_NAME", 0);
            Property(p => p.FlowNodeId).AddColumnIndex("IX_TASK_FLOW_ID", 0);
            Property(p => p.Assignee).HasMaxLength(255).IsUnicode(unicode);
            //Property(p => p.BusinessKey).HasMaxLength(255).IsUnicode(unicode);
            //Property(p => p.Category).HasMaxLength(255).IsUnicode(unicode);
            //Property(p => p.Description).HasMaxLength(255).IsUnicode(unicode);
            //Property(p => p.ExecutionId).HasMaxLength(255).IsUnicode(unicode);
            //Property(p => p.Name).HasMaxLength(255).IsUnicode(unicode);
            //Property(p => p.Owner).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.TenantId).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.CreatedBy).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.ModifiedBy).HasMaxLength(255).IsUnicode(unicode);

            // Table & Column Mappings
            ToTable(Config.Instance.Tables.ProcessTask);
            MapToStoredProcedures();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DatabaseGeneratedAttribute"/> class.
        /// </summary>
        /// <param name="databaseGeneratedOption">The pattern used to generate values for the property in the database.</param>
        public DatabaseGeneratedAttribute(DatabaseGeneratedOption databaseGeneratedOption) {
            if (!(Enum.IsDefined(typeof(DatabaseGeneratedOption), databaseGeneratedOption))) {
                throw new ArgumentOutOfRangeException("databaseGeneratedOption");
            }

            DatabaseGeneratedOption = databaseGeneratedOption;
        }
Example #9
0
        public DefinitionMap()
        {
            DatabaseGeneratedOption option = Config.Instance.GeneratedOption;
            bool unicode = Config.Instance.UnicodeString;

            // Primary Key
            HasKey(t => new { t.DefinitionId });

            // Properties
            Property(p => p.DefinitionId).HasDatabaseGeneratedOption(option);
            Property(p => p.DeploymentId).AddColumnIndex("IX_DEFINITION_DEPLOYMENT_ID", 0);
            Property(p => p.Id).HasMaxLength(255).IsRequired().IsUnicode(unicode).AddColumnIndex("IX_DEFINITION_ID", 0);
            Property(p => p.Name).HasMaxLength(255).IsUnicode(unicode).AddColumnIndex("IX_DEFINITION_NAME", 0);
            //Property(p => p.DiagramResourceName).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.Name).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.Description).IsUnicode(unicode);
            //Property(p => p.Resource).HasMaxLength(255).IsUnicode(unicode);
            //Property(p => p.TenantId).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.Exporter).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.ExporterVersion).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.ExpressionLanguage).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.TypeLanguage).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.TargetNamespace).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.CreatedBy).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.ModifiedBy).HasMaxLength(255).IsUnicode(unicode);

            // Table & Column Mappings
            ToTable(Config.Instance.Tables.Definition);
            MapToStoredProcedures();
        }
Example #10
0
 public DatabaseGeneratedAttribute(DatabaseGeneratedOption databaseGeneratedOption)
 {
     if (!Enum.IsDefined(typeof(DatabaseGeneratedOption), databaseGeneratedOption))
     {
         throw new ArgumentOutOfRangeException("databaseGeneratedOption");
     }
     this.DatabaseGeneratedOption = databaseGeneratedOption;
 }
        /// <summary>
        /// 声明表主键
        /// </summary>
        /// <typeparam name="TProperty">主键类型</typeparam>
        /// <param name="expr">主键</param>
        /// <param name="option">主键生成方式
        /// </param>
        public void HasKey <TProperty>(Expression <Func <TEntity, TProperty> > expr, DatabaseGeneratedOption option)
        {
            var name     = ((MemberExpression)expr.Body).Member.Name;
            var property = _properties[name];

            property.Property.IsKey  = true;
            property.Property.Option = option;
        }
Example #12
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="DatabaseGeneratedAttribute" /> class.
        /// </summary>
        /// <param name="databaseGeneratedOption">The pattern used to generate values for the property in the database.</param>
        public DatabaseGeneratedAttribute(DatabaseGeneratedOption databaseGeneratedOption)
        {
            if (!(Enum.IsDefined(typeof(DatabaseGeneratedOption), databaseGeneratedOption)))
            {
                throw new ArgumentOutOfRangeException(nameof(databaseGeneratedOption));
            }

            DatabaseGeneratedOption = databaseGeneratedOption;
        }
Example #13
0
        /// <summary>	Adds a database generated attribute to 'option'. </summary>
        ///
        /// <param name="propertyBuilder">	The property builder. </param>
        /// <param name="option">		    The option. </param>
        private void AddDatabaseGeneratedAttribute(PropertyBuilder propertyBuilder, DatabaseGeneratedOption option)
        {
            Type attrType = typeof(DatabaseGeneratedAttribute);
            var  attr     = new CustomAttributeBuilder(attrType.GetConstructor(
                                                           new[] { typeof(DatabaseGeneratedOption) }),
                                                       new object[] { option },
                                                       new PropertyInfo[] { },
                                                       new object[] { });

            propertyBuilder.SetCustomAttribute(attr);
        }
        protected EntityTypeConfigurationBaseInt(string tableName, DatabaseGeneratedOption autoGeneratedOption)
            : base(tableName)
        {
            // Primary Key
            HasKey(t => t.Id);

            // Properties
            Property(t => t.Id)
            .HasDatabaseGeneratedOption(autoGeneratedOption)
            .IsRequired()
            .HasColumnName("Id");
        }
 public BaseEntityLongConfiguration(DatabaseGeneratedOption DGO = DatabaseGeneratedOption.Identity)
 {
     // Primary Key
     this.HasKey(t => t.Id);
     // Properties
     //Id is an indent allocated by DB
     this.Property(t => t.Id).HasDatabaseGeneratedOption(DGO); // default to db generated
     this.Property(t => t.RowVersion)                          // for concurrency
     .IsRequired()
     .IsFixedLength()
     .HasMaxLength(8)
     .IsRowVersion();
 }
Example #16
0
 /// <summary>
 /// Configures how values for the property are generated by the database.
 /// </summary>
 /// <param name="databaseGeneratedOption"> The pattern used to generate values for the property in the database. </param>
 /// <returns>
 /// The same <see cref="T:System.Data.Entity.ModelConfiguration.Configuration.ConventionPrimitivePropertyConfiguration" /> instance so that multiple calls can be chained.
 /// </returns>
 /// <remarks>
 /// Calling this will have no effect once it has been configured.
 /// </remarks>
 public virtual ConventionPrimitivePropertyConfiguration HasDatabaseGeneratedOption(
     DatabaseGeneratedOption databaseGeneratedOption)
 {
     if (!Enum.IsDefined(typeof(DatabaseGeneratedOption), (object)databaseGeneratedOption))
     {
         throw new ArgumentOutOfRangeException(nameof(databaseGeneratedOption));
     }
     if (this._configuration() != null && !this._configuration().DatabaseGeneratedOption.HasValue)
     {
         this._configuration().DatabaseGeneratedOption = new DatabaseGeneratedOption?(databaseGeneratedOption);
     }
     return(this);
 }
 private static void AssertHasExpectedDatabaseGeneratedOption <T>(DatabaseGeneratedOption databaseGeneratedOption,
                                                                  DatabaseGeneratedAttribute attrib, PropertyData <T> propData)
 {
     Assert.AreEqual(databaseGeneratedOption,
                     attrib.DatabaseGeneratedOption,
                     new[]
     {
         "Expected [DatabaseGenerated(DatabaseGeneratedOption.",
         databaseGeneratedOption.ToString(),
         ")] on ",
         ErrorSuffixFor <T>(propData.PropertyPath)
     }.JoinWith(""));
 }
        /// <summary>
        /// Configures how values for the property are generated by the database.
        /// </summary>
        /// <param name="databaseGeneratedOption">
        /// The pattern used to generate values for the property in the database.
        /// Setting 'null' will cause the default option to be used, which may be 'None', 'Identity', or 'Computed' depending
        /// on the type of the property, its semantics in the model (e.g. primary keys are treated differently), and which
        /// set of conventions are being used.
        /// </param>
        /// <returns> The same PrimitivePropertyConfiguration instance so that multiple calls can be chained. </returns>
        public PrimitivePropertyConfiguration HasDatabaseGeneratedOption(
            DatabaseGeneratedOption? databaseGeneratedOption)
        {
            if (!((databaseGeneratedOption == null)
                  || Enum.IsDefined(typeof(DatabaseGeneratedOption), databaseGeneratedOption)))
            {
                throw new ArgumentOutOfRangeException("databaseGeneratedOption");
            }

            Configuration.DatabaseGeneratedOption = databaseGeneratedOption;

            return this;
        }
Example #19
0
        public override IEnumerable <DynamicPropertyInfo> GetStructuralProperties(String tableName)
        {
            IEdmEntityType edmEntityType = OeEdmClrHelper.GetEntitySet(_edmModel, tableName).EntityType();
            Type           clrType       = _edmModel.GetClrType(edmEntityType);

            foreach (IEdmStructuralProperty structuralProperty in edmEntityType.StructuralProperties())
            {
                PropertyInfo property = clrType.GetProperty(structuralProperty.Name);
                DatabaseGeneratedAttribute attribute = property.GetCustomAttribute <DatabaseGeneratedAttribute>();
                DatabaseGeneratedOption    databaseGeneratedOption = attribute == null ?
                                                                     DatabaseGeneratedOption.None : databaseGeneratedOption = attribute.DatabaseGeneratedOption;
                yield return(new DynamicPropertyInfo(structuralProperty.Name, property.PropertyType, databaseGeneratedOption));
            }
        }
        private static Incremento ConverterDatabaseGeneratedOptionParaIncremento(DatabaseGeneratedOption databaseGeneratedOption)
        {
            if (databaseGeneratedOption == DatabaseGeneratedOption.None)
            {
                return(Incremento.Nenhum);
            }

            if (databaseGeneratedOption == DatabaseGeneratedOption.Identity)
            {
                return(Incremento.Identity);
            }

            return(Incremento.Calculado);
        }
Example #21
0
        /// <summary>
        ///     Configures how values for the property are generated by the database.
        /// </summary>
        /// <param name="databaseGeneratedOption"> The pattern used to generate values for the property in the database. </param>
        /// <returns>
        ///     The same <see cref="LightweightPropertyConfiguration" /> instance so that multiple calls can be chained.
        /// </returns>
        /// <remarks>
        ///     Calling this will have no effect once it has been configured.
        /// </remarks>
        public virtual LightweightPropertyConfiguration HasDatabaseGeneratedOption(
            DatabaseGeneratedOption databaseGeneratedOption)
        {
            if (!Enum.IsDefined(typeof(DatabaseGeneratedOption), databaseGeneratedOption))
            {
                throw new ArgumentOutOfRangeException("databaseGeneratedOption");
            }

            if (_configuration().DatabaseGeneratedOption == null)
            {
                _configuration().DatabaseGeneratedOption = databaseGeneratedOption;
            }

            return(this);
        }
Example #22
0
        public ProcessFlowMap()
        {
            DatabaseGeneratedOption option = Config.Instance.GeneratedOption;
            bool unicode = Config.Instance.UnicodeString;

            // Primary Key
            HasKey(t => new { t.ProcessFlowId });

            // Properties
            Property(p => p.ProcessFlowId).HasDatabaseGeneratedOption(option);

            // Table & Column Mappings
            ToTable(Config.Instance.Tables.ProcessFlow);
            MapToStoredProcedures();
        }
Example #23
0
        public CommentMap()
        {
            DatabaseGeneratedOption option = Config.Instance.GeneratedOption;
            bool unicode = Config.Instance.UnicodeString;

            // Primary Key
            HasKey(t => new { t.CommentId });

            // Properties
            Property(p => p.CommentId).HasDatabaseGeneratedOption(option);
            Property(p => p.User).HasMaxLength(255).IsUnicode(unicode);

            // Table & Column Mappings
            ToTable(Config.Instance.Tables.Comment);
            MapToStoredProcedures();
        }
Example #24
0
        public ProcessVariablesMap()
        {
            DatabaseGeneratedOption option = Config.Instance.GeneratedOption;
            bool unicode = Config.Instance.UnicodeString;

            // Primary Key
            HasKey(t => new { t.ProcessVariablesId });

            // Properties
            Property(p => p.ProcessVariablesId).HasDatabaseGeneratedOption(option);
            Property(p => p.ProcessInstanceId).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute("IX_PROCESS_VARIABLE_INSTANCE_ID")));

            // Table & Column Mappings
            ToTable(Config.Instance.Tables.ProcessVariables);
            MapToStoredProcedures();
        }
Example #25
0
        public ActivityMap()
        {
            DatabaseGeneratedOption option = Config.Instance.GeneratedOption;
            bool unicode = Config.Instance.UnicodeString;

            // Primary Key
            HasKey(t => new { t.ActivityId });

            // Properties
            Property(p => p.ActivityId).HasDatabaseGeneratedOption(option);
            Property(p => p.ProcessInstanceId).AddColumnIndex("IX_ACTIVITY_PROCESS_INSTANCE", 0);
            Property(p => p.Id).HasMaxLength(255).IsUnicode(unicode).AddColumnIndex("IX_ACTIVITY_ID", 0);

            // Table & Column Mappings
            ToTable(Config.Instance.Tables.Activity);
            MapToStoredProcedures();
        }
Example #26
0
        public DefinitionVariableMap()
        {
            DatabaseGeneratedOption option = Config.Instance.GeneratedOption;
            bool unicode = Config.Instance.UnicodeString;

            // Primary Key
            HasKey(t => new { t.DefinitionVariableId });

            // Properties
            Property(p => p.DefinitionVariableId).HasDatabaseGeneratedOption(option);
            Property(p => p.DefinitionId).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute("IX_DEFINITION_VARIABLE_DEFINITION_ID")));
            Property(p => p.VariableName).HasMaxLength(255).IsRequired().IsUnicode(unicode).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute("IX_DEFINITION_VARIABLE_NAME")));

            // Table & Column Mappings
            ToTable(Config.Instance.Tables.DefinitionVariable);
            MapToStoredProcedures();
        }
Example #27
0
        public ApprovalMap()
        {
            DatabaseGeneratedOption option = Config.Instance.GeneratedOption;
            bool unicode = Config.Instance.UnicodeString;

            // Primary Key
            HasKey(t => new { t.ApprovalId });

            // Properties
            Property(p => p.ApprovalId).HasDatabaseGeneratedOption(option);
            Property(p => p.Assignee).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.Group).HasMaxLength(255).IsUnicode(unicode);

            // Table & Column Mappings
            ToTable(Config.Instance.Tables.Approval);
            MapToStoredProcedures();
        }
Example #28
0
        public void SetAutoGeneratedOption(DatabaseGeneratedOption option)
        {
            if (IsOwnsOne && option != DatabaseGeneratedOption.None)
            {
                throw new ArgumentException(
                          String.Format(
                              MessageConstants.InvalidPropertyOption,
                              Name,
                              nameof(DatabaseGeneratedOption),
                              option,
                              "OwnsOne Properties"
                              )
                          );
            }

            AutoGeneratedOption = option;
        }
Example #29
0
        public DataObjectMap()
        {
            DatabaseGeneratedOption option = Config.Instance.GeneratedOption;
            bool unicode = Config.Instance.UnicodeString;

            // Primary Key
            HasKey(t => new { t.DataObjectId });

            // Properties
            Property(p => p.DataObjectId).HasDatabaseGeneratedOption(option);
            Property(p => p.Id).HasMaxLength(255).IsUnicode(unicode).IsRequired().HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute("IX_DATA_OBJECT_ID")));
            Property(p => p.Name).HasMaxLength(255).IsUnicode(unicode).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute("IX_DATA_OBJECT_NAME")));
            Property(p => p.ItemSubjectRef).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute("IX_DATA_OBJECT_ITEM_SUBJECT_REF")));

            // Table & Column Mappings
            ToTable(Config.Instance.Tables.DataObject);
            MapToStoredProcedures();
        }
Example #30
0
        public SequenceFlowMap()
        {
            DatabaseGeneratedOption option = Config.Instance.GeneratedOption;
            bool unicode = Config.Instance.UnicodeString;

            // Primary Key
            HasKey(t => new { t.Id });

            // Properties
            Property(p => p.Id).HasDatabaseGeneratedOption(option);
            Property(p => p.SequenceFlowId).IsRequired().HasMaxLength(64).IsUnicode(unicode).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute("IX_SEQUENCE_FLOW_ID")));
            Property(p => p.SequenceFlowName).HasMaxLength(64).IsUnicode(unicode).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute("IX_SEQUENCE_FLOW_NAME")));
            Property(p => p.SourceRef).HasMaxLength(64).IsUnicode(unicode).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute("IX_SEQUENCE_SOURCE_REF")));
            Property(p => p.TargetRef).HasMaxLength(64).IsUnicode(unicode).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute("IX_SEQUENCE_TARGET_REF")));

            // Table & Column Mappings
            ToTable(Config.Instance.Tables.SequenceFlow);
            MapToStoredProcedures();
        }
        public void Apply_SetsDatabaseGeneratedAttributes(DatabaseGeneratedOption option)
        {
            // Arrange
            Mock<PropertyInfo> property = new Mock<PropertyInfo>();
            property.Setup(p => p.Name).Returns("Property");
            property.Setup(p => p.PropertyType).Returns(typeof(int));
            property.Setup(p => p.GetCustomAttributes(It.IsAny<bool>()))
                .Returns(new[] { new DatabaseGeneratedAttribute(option) });

            Mock<EntityTypeConfiguration> entityType = new Mock<EntityTypeConfiguration>(MockBehavior.Strict);
            Mock<PrimitivePropertyConfiguration> primitiveProperty =
                new Mock<PrimitivePropertyConfiguration>(property.Object, entityType.Object);
            primitiveProperty.Object.AddedExplicitly = false;

            // Act
            new DatabaseGeneratedAttributeEdmPropertyConvention().Apply(primitiveProperty.Object, entityType.Object);

            // Assert
            Assert.Equal(option, primitiveProperty.Object.StoreGeneratedPattern);
        }
Example #32
0
        public DeploymentMap()
        {
            DatabaseGeneratedOption option = Config.Instance.GeneratedOption;
            bool unicode = Config.Instance.UnicodeString;

            // Primary Key
            HasKey(t => new { t.Id });

            // Properties
            Property(p => p.Id).HasDatabaseGeneratedOption(option);
            Property(p => p.DeploymentId).HasMaxLength(64).IsRequired().IsUnicode(unicode).AddColumnIndex("IX_DEPLOYMENT_ID", 0);
            Property(p => p.DeploymentName).HasMaxLength(64).IsRequired().IsUnicode(unicode).AddColumnIndex("IX_DEPLOYMENT_NAME_CATEGORY_TENANT", 0);
            //Property(p => p.Category).IsRequired().HasMaxLength(255).IsUnicode(unicode).AddColumnIndex("IX_DEPLOYMENT_NAME_CATEGORY_TENANT", 1);
            Property(p => p.TenantId).HasMaxLength(64).IsUnicode(unicode).AddColumnIndex("IX_DEPLOYMENT_NAME_CATEGORY_TENANT", 1);
            Property(p => p.CreatedBy).HasMaxLength(64).IsUnicode(unicode);
            Property(p => p.ModifiedBy).HasMaxLength(64).IsUnicode(unicode);

            // Table & Column Mappings
            ToTable(Config.Instance.Tables.Deployment);
            MapToStoredProcedures();
        }
Example #33
0
        public ProcessMap()
        {
            DatabaseGeneratedOption option = Config.Instance.GeneratedOption;
            bool unicode = Config.Instance.UnicodeString;

            // Primary Key
            HasKey(t => new { t.Id });

            // Properties
            Property(p => p.Id).HasDatabaseGeneratedOption(option);
            Property(p => p.DeploymentId).IsRequired().AddColumnIndex("IX_PROCESS_DEPLOYMENT_ID", 0);
            Property(p => p.ProcessId).IsRequired().HasMaxLength(255).IsUnicode(unicode).AddColumnIndex("IX_PROCESS_ID", 0);
            Property(p => p.ProcessName).HasMaxLength(255).IsUnicode(unicode).AddColumnIndex("IX_PROCESS_NAME", 0);
            //Property(p => p.IsActive).AddColumnIndex("IX_PROCESS_ID", 1).AddColumnIndex("IX_PROCESS_NAME", 1);
            Property(p => p.CreatedBy).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.ModifiedBy).HasMaxLength(255).IsUnicode(unicode);

            // Table & Column Mappings
            ToTable(Config.Instance.Tables.BpmnProcess);
            MapToStoredProcedures();
        }
Example #34
0
        public ProcessInstanceMap()
        {
            DatabaseGeneratedOption option = Config.Instance.GeneratedOption;
            bool unicode = Config.Instance.UnicodeString;

            // Primary Key
            HasKey(t => t.Id);

            // Properties
            Property(p => p.Id).HasDatabaseGeneratedOption(option);
            //Property(p => p.ProcessInstanceId).AddColumnIndex("IX_PROCESS_INSTANCE_ID", 0, false, false);
            //Property(p => p.ProcessInstanceId).HasMaxLength(255).IsFixedLength().IsUnicode(unicode);
            Property(p => p.TenantId).HasMaxLength(255).IsUnicode(unicode).AddColumnIndex("IX_PROCESS_INSTANCE_ID", 1);
            Property(p => p.BusinessKey).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.ProcessId).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.CreatedBy).HasMaxLength(255).IsUnicode(unicode);
            Property(p => p.ModifiedBy).HasMaxLength(255).IsUnicode(unicode);

            // Table & Column Mappings
            ToTable(Config.Instance.Tables.ProcessInstance);
            MapToStoredProcedures();
        }
 public DatabaseGeneratedAttribute(DatabaseGeneratedOption databaseGeneratedOption);
 public static void Ctor_DatabaseGeneratedOption(DatabaseGeneratedOption databaseGeneratedOption)
 {
     DatabaseGeneratedAttribute attribute = new DatabaseGeneratedAttribute(databaseGeneratedOption);
     Assert.Equal(databaseGeneratedOption, attribute.DatabaseGeneratedOption);
 }
 public StoreGeneratedPatternAnnotation(IEdmElement element, DatabaseGeneratedOption option)
 {
     this.element = element;
     this.value = new EdmStringConstant(EdmCoreModel.Instance.GetString(isNullable: false), option.ToString());
 }
 /// <summary>
 /// Configures the property to have the given <paramref name="databaseGeneratedOption"/>.
 /// </summary>
 /// <param name="databaseGeneratedOption">Target DatabaseGeneratedOption.</param>
 /// <returns>Returns itself so that multiple calls can be chained.</returns>
 public PrimitivePropertyConfiguration HasStoreGeneratedPattern(DatabaseGeneratedOption databaseGeneratedOption)
 {
     StoreGeneratedPattern = databaseGeneratedOption;
     return this;
 }
        /// <summary>
        ///     Configures how values for the property are generated by the database.
        /// </summary>
        /// <param name="databaseGeneratedOption"> The pattern used to generate values for the property in the database. </param>
        /// <returns>
        ///     The same <see cref="LightweightPropertyConfiguration" /> instance so that multiple calls can be chained.
        /// </returns>
        /// <remarks>
        ///     Calling this will have no effect once it has been configured.
        /// </remarks>
        public virtual LightweightPropertyConfiguration HasDatabaseGeneratedOption(
            DatabaseGeneratedOption databaseGeneratedOption)
        {
            if (!Enum.IsDefined(typeof(DatabaseGeneratedOption), databaseGeneratedOption))
            {
                throw new ArgumentOutOfRangeException("databaseGeneratedOption");
            }

            if (_configuration().DatabaseGeneratedOption == null)
            {
                _configuration().DatabaseGeneratedOption = databaseGeneratedOption;
            }

            return this;
        }
 public override LightweightPropertyConfiguration HasDatabaseGeneratedOption(DatabaseGeneratedOption databaseGeneratedOption)
 {
     return this;
 }
 public static void Ctor_DatabaseGeneratedOption_UndefinedOption_ThrowsArgumentOutOfRangeException(DatabaseGeneratedOption databaseGeneratedOption)
 {
     Assert.Throws<ArgumentOutOfRangeException>("databaseGeneratedOption", () => new DatabaseGeneratedAttribute(databaseGeneratedOption));
 }
 /// <summary>
 /// Indicates that the property is mapped to a database generated field.
 /// This does not cover default values generated by the database (please use <see cref="ExcludeFromInserts"/> and <see cref="RefreshOnInserts"/> for this scenario).
 /// </summary>
 public PropertyMapping SetDatabaseGenerated(DatabaseGeneratedOption option)
 {
     switch (option)
     {
         case DatabaseGeneratedOption.Computed:
             this.IsExcludedFromInserts = true;
             this.IsExcludedFromUpdates = true;
             this.IsRefreshedOnInserts = true;
             this.IsRefreshedOnUpdates = true;
             break;
         case DatabaseGeneratedOption.Identity:
             this.IsExcludedFromInserts = true;
             this.IsExcludedFromUpdates = true;
             this.IsRefreshedOnInserts = true;
             this.IsRefreshedOnUpdates = false;
             break;
         case DatabaseGeneratedOption.None:
             this.IsExcludedFromInserts = false;
             this.IsExcludedFromUpdates = false;
             this.IsRefreshedOnInserts = false;
             this.IsRefreshedOnUpdates = false;
             break;
         default:
             throw new NotSupportedException($"Option {option} is not supported.");
     }
     return this;
 }