Error EF Update Method with Firebird 2.5

0

When I try to update an entity Firebird is returning this error "Implementation limit exceeded block size exceeds implementation restriction", simply get the entity of the bank and has to update without changing anything in it, so I saw the link FaqFirebird this error occurs when the select exceeds the size of 64kb, however I want to insert an image in the database that is a Blob field.

Class that defines the table

public class Hospede : EntityBase
{
    public string Nome { get; set; }
    public string Email { get; set; }
    public string Sexo { get; set; }
    public string Telefone { get; set; }
    public string TelefoneResidencial { get; set; }
    public string TelefoneCelular { get; set; }
    public DateTime? DataNascimento { get; set; }
    public string RG { get; set; }
    public string CPF { get; set; }
    public string Passaporte { get; set; }
    public string Nacionalidade { get; set; }
    public byte[] AssinaturaDigital { get; set; }
    #region Endereço
    public string Endereco { get; set; }
    public int Numero { get; set; }
    public string Complemento { get; set; }
    public string Bairro { get; set; }
    public string Cidade { get; set; }
    public string Estado { get; set; }
    public string Pais { get; set; }
    public string Cep { get; set; }
    #endregion

    public virtual ICollection<Reserva> Reserva { get; set; }
}

Entity Mapping

public class HospedeMap : IEntityTypeConfiguration<Hospede>
{
    public void Configure(EntityTypeBuilder<Hospede> map)
    {
        map.ToTable("TABHOSPE");
        map.HasKey(x => x.Id);
        map.Property(x => x.Id)
            .HasColumnName("F_COD");
        map.Property(x => x.Nome)
            .HasColumnName("F_NOME");
        map.Property(x => x.Email)
            .HasColumnName("EMAIL");
        map.Property(x => x.Sexo)
            .HasColumnName("F_SEXO");
        map.Property(x => x.Telefone)
            .HasColumnName("F_FONE");
        map.Property(x => x.TelefoneResidencial)
            .HasColumnName("FONERES");
        map.Property(x => x.TelefoneCelular)
            .HasColumnName("FONECEL");
        map.Property(x => x.DataNascimento)
            .HasColumnName("F_NASCIM");
        map.Property(x => x.RG)
            .HasColumnName("F_RG");
        map.Property(x => x.CPF)
            .HasColumnName("F_CPF");
        map.Property(x => x.Passaporte)
            .HasColumnName("PASSAPORT");
        map.Property(x => x.Nacionalidade)
            .HasColumnName("NACIONALIDADE");
        map.Property(x => x.DataNascimento)
            .HasColumnName("F_NASCIM");
        map.Property(x => x.AssinaturaDigital)
            .HasColumnName("ASSINATURA_DIGITAL");
        map.Property(x => x.Endereco)
            .HasColumnName("F_ENDERECO");
        map.Property(x => x.Numero)
            .HasColumnName("NUMERO");
        map.Property(x => x.Complemento)
            .HasColumnName("COMPLEMENTO");
        map.Property(x => x.Bairro)
            .HasColumnName("F_BAIRRO");
        map.Property(x => x.Cidade)
            .HasColumnName("F_CIDADE");
        map.Property(x => x.Estado)
            .HasColumnName("F_ESTADO");
        map.Property(x => x.Pais)
            .HasColumnName("PAIS");
        map.Property(x => x.Cep)
            .HasColumnName("F_CEP");
        map.HasMany(x => x.Reserva)
            .WithOne(x => x.Hospede);
    }
}

Table Structure

create table TABHOSPE{
   F_COD integer,
   F_NOME varchar(100),
   F_FONE varchar(20),
   F_SEXO varchar(1),
   F_NASCIM date,
   F_ENDERECO varchar(60),
   F_BAIRRO varchar(60),
   F_CIDADE varchar(60),
   F_ESTADO varchar(2),
   F_CEP varchar(9),
   F_RG varchar(15),
   F_CPF varchar(15),
   NACIONALIDADE varchar(60),
   PAIS varchar(60),
   FONERES varchar(20),
   FONECEL varchar(20),
   EMAIL varchar(80),
   PASSAPORT varchar(20),
   COMPLEMENTO varchar(30),
   NUMERO integer,
   ASSINATURA_DIGITAL Blob
}
    
asked by anonymous 29.06.2018 / 20:55

1 answer

1

Unable to write large blob fields at once. As you yourself have figured out the maximum size of the SQL statements in Firebird is 64 Kb.

What you should do to circumvent this limit is to break the blob into several smaller parts and first execute an INSERT to insert the first part, followed by UPDATE's that concatenate the other parts. You should do everything in a single transaction and in the end give a COMMIT to effect the change or ROLLBACK to undo.

To concatenate blob fields you must use a function that performs this procedure without loss or corruption, because Firebird does not have this feature natively. I recommend using FreeAdhoc library, it has many functions for complete manipulation of blob fields.

FreeAdhoc's official website: link

Function page for blob field manipulation: link

The library must be installed in your database so that it can be used directly in SQL statements.

    
30.06.2018 / 17:51