Example #1
0
        public static Guid InsertEntityField(int entityFieldTypeId, string name, string description, int dataTypeId, string defaultValue
                                             , bool allowDBNull, bool unique, int maxLength, string minValue, string maxValue, int decimalDigits, int orderNumber
                                             , Guid entityId, Guid organizationId, Guid?instanceId, bool active)
        {
            ClientDataSet.EntityFieldDataTable table = new ClientDataSet.EntityFieldDataTable();
            ClientDataSet.EntityFieldRow       row   = table.NewEntityFieldRow();

            row.EntityFieldId     = Guid.NewGuid();
            row.EntityFieldTypeId = entityFieldTypeId;
            row.Name        = name;
            row.Description = description;
            row.DataTypeId  = dataTypeId;
            if ((EntityFieldType)entityFieldTypeId == EntityFieldType.Value)
            {
                row.DefaultValue = defaultValue;
            }
            row.AllowDBNull = allowDBNull;
            row.Unique      = unique;
            row.MaxLength   = maxLength;
            if (minValue != null)
            {
                row.MinValue = minValue;
            }
            if (maxValue != null)
            {
                row.MaxValue = maxValue;
            }
            row.DecimalDigits  = decimalDigits;
            row.OrderNumber    = orderNumber;
            row.EntityId       = entityId;
            row.OrganizationId = organizationId;
            if (instanceId.HasValue)
            {
                row.InstanceId = instanceId.Value;
            }
            row.Active = active;

            table.AddEntityFieldRow(row);

            using (EntityFieldTableAdapter adapter = new EntityFieldTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                adapter.Update(row);
            }

            RemoveFromCache();

            return(row.EntityFieldId);
        }