コード例 #1
0
        /// <summary>
        /// Updates the integration service exposed type field.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <exception cref="System.ArgumentNullException">dto</exception>
        /// <exception cref="System.Data.DBConcurrencyException"></exception>
        public void UpdateIntegrationServiceExposedTypeField(IntegrationServiceExposedTypeFieldDto dto)
        {
            const string CommandText = @"
UPDATE [dbo].[IntegrationServiceExposedTypeFields]
SET
     [TypeId] = @typeId
    ,[LastModifiedOn] = GETDATE()
    ,[Guid] = @guid
    ,[Name] = @name
    ,[Namespace] = @namespace
    ,[TypeGuid] = @typeGuid
    ,[AllowMultiple] = @allowMultiple
    ,[SerializeAsSequence] = @serializeAsSequence
    ,[IsNullable] = @isNullable
WHERE [Id] = @id;";

            if (dto == null)
                throw new ArgumentNullException("dto");

            using (var cmd = new SqlCommand(CommandText))
            {
                cmd.Parameters.AddWithValue("@id", dto.Id);
                cmd.Parameters.AddWithValue("@typeId", dto.TypeId);
                cmd.Parameters.AddWithValue("@guid", dto.Guid);
                cmd.Parameters.AddWithValue("@name", dto.Name);
                cmd.Parameters.AddWithValue("@namespace", dto.Namespace);
                cmd.Parameters.AddWithValue("@typeGuid", AdoHelper.NullCheck(dto.TypeGuid));
                cmd.Parameters.AddWithValue("@allowMultiple", dto.AllowMultiple);
                cmd.Parameters.AddWithValue("@serializeAsSequence", dto.SerializeAsSequence);
                cmd.Parameters.AddWithValue("@isNullable", dto.IsNullable);

                var rowsAffected = Database.Execute(cmd);
                if (rowsAffected == 0)
                    throw new DBConcurrencyException(ConcurencyException);
            }
        }
コード例 #2
0
        /// <summary>
        /// Reads the integration service exposed type fields.
        /// </summary>
        /// <param name="settingsDto">The settings dto.</param>
        /// <param name="reader">The reader.</param>
        private static void ReadIntegrationServiceExposedTypeFields(IntegrationServiceCreationSettingsDto settingsDto, IDataReader reader)
        {
            reader.NextResult();

            int? typeId = null;
            IntegrationServiceExposedTypeDto type = null;

            while (reader.Read())
            {
                var fieldDto = new IntegrationServiceExposedTypeFieldDto
                                   {
                                       Id = reader.GetInt32(0),
                                       TypeId = reader.GetInt32(1),
                                       Guid = reader.GetGuid(2),
                                       Name = reader.GetString(3),
                                       Namespace = reader.GetString(4),
                                       TypeGuid = reader.GetGuid(5),
                                       AllowMultiple = reader.GetBoolean(6),
                                       SerializeAsSequence = reader.GetBoolean(7),
                                       IsNullable = reader.GetBoolean(8)
                                   };

                if (fieldDto.TypeId != typeId)
                {
                    type = settingsDto.Types.First(t => t.Id == fieldDto.TypeId);
                    typeId = fieldDto.TypeId;
                }

                type.Fields.Add(fieldDto);
            }
        }
コード例 #3
0
        /// <summary>
        /// Inserts the integration service exposed type field.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <exception cref="System.ArgumentNullException">dto</exception>
        /// <exception cref="System.Data.DBConcurrencyException"></exception>
        public void InsertIntegrationServiceExposedTypeField(IntegrationServiceExposedTypeFieldDto dto)
        {
            const string CommandText = @"
INSERT INTO [dbo].[IntegrationServiceExposedTypeFields]
(
     [TypeId]
    ,[LastModifiedOn]
    ,[Guid]
    ,[Name]
    ,[Namespace]
    ,[TypeGuid]
    ,[AllowMultiple]
    ,[SerializeAsSequence]
    ,[IsNullable]
)
VALUES
(
     @typeId
    ,GETDATE()
    ,@guid
    ,@name
    ,@namespace
    ,@typeGuid
    ,@allowMultiple
    ,@serializeAsSequence
    ,@isNullable
);

SET @id = SCOPE_IDENTITY();";

            if (dto == null)
                throw new ArgumentNullException("dto");

            using (var cmd = new SqlCommand(CommandText))
            {
                var idParam = cmd.Parameters.Add("@id", SqlDbType.Int);
                idParam.Direction = ParameterDirection.Output;

                cmd.Parameters.AddWithValue("@typeId", dto.TypeId);
                cmd.Parameters.AddWithValue("@guid", dto.Guid);
                cmd.Parameters.AddWithValue("@name", dto.Name);
                cmd.Parameters.AddWithValue("@namespace", dto.Namespace);
                cmd.Parameters.AddWithValue("@typeGuid", AdoHelper.NullCheck(dto.TypeGuid));
                cmd.Parameters.AddWithValue("@allowMultiple", dto.AllowMultiple);
                cmd.Parameters.AddWithValue("@serializeAsSequence", dto.SerializeAsSequence);
                cmd.Parameters.AddWithValue("@isNullable", dto.IsNullable);

                var rowsAffected = Database.Execute(cmd);
                if (rowsAffected == 0)
                    throw new DBConcurrencyException(ConcurencyException);

                dto.Id = (int)idParam.Value;
            }
        }