0

Here is the mapping:

builder.Property(c => c.Nome)
    .IsRequired()
    .HasMaxLength(100)
    .HasColumnName("NOME");

builder.Property(c => c.Apelido)
    .IsRequired()
    .HasMaxLength(100)
    .HasColumnName("APELIDO");

Here is my repository:

public async Task<Operadora> ObterPorNome(string nome, string apelido)
{
    return await _db.Set<Operadora>()
        .Where(c => c.Nome.ToLower().StartsWith(nome.ToLower()) 
                 || c.Apelido.ToLower().StartsWith(apelido.ToLower()))
        .FirstOrDefaultAsync();
}

And in the data base has the same length, but when make the query at the repository return the following error:

FirebirdSql.Data.FirebirdClient.FbException (0x80004005): Dynamic SQL Error SQL error code = -204 Implementation limit exceeded block size exceeds implementation restriction

Does anyone know what is happening?

I've already tried to increase the length to 300, but it didn't work.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Duarte_hrd
  • 16
  • 1
  • You could lower case the parameter values outside the query? Does your entire selected row exceed 64KB? http://www.firebirdfaq.org/faq299/ – Jeremy Lakeman Mar 30 '23 at 01:59
  • The error comes from the Firebird driver, not Entity Framework. Apart from that, using `ToLower()` or any other function when filtering is a bad idea for all databases though because it prevents the database from using any indexes created using the original field values. If you want to perform case-insensitive queries, use a case-insensitive collation or index. In some databases you can create an index over function results. – Panagiotis Kanavos Mar 30 '23 at 08:48
  • 1
    Could you include the query this generated? As Jeremy says, possibly you're doing something that causes the total size of a row or the total size of all parameters to exceed the maximum size (64 KiB). Also, in my experience, for this type of question, you might not get an answer here. Consider asking on https://groups.google.com/g/firebird-net-provider as well (and if you receive an answer there, consider posting the solution here as well). – Mark Rotteveel Mar 30 '23 at 08:48
  • [This Firebird FAQ](https://www.firebirdfaq.org/faq299/) explains that Unicode and UTF8 text uses 3 and 4 bytes per character, instead of the 2 (for UTF16) or 1-3 (for UTF8) you'd expect. Perhaps the actual row size is indeed larger than the limit, especially if there are large note-like fields. Do you really need *all* object properties? Perhaps you should use `Select` to retrieve only what you need? – Panagiotis Kanavos Mar 30 '23 at 08:54
  • 1
    @PanagiotisKanavos Firebird's UTF8 actually uses 1-4 bytes per codepoint to encode Unicode codepoints, like the normal UTF-8 format (if you expect 1-3 bytes, you're thinking of MySQL's UTF8 which is limited to max 3 bytes, or Firebird's UNICODE_FSS, incorrectly referenced as UNICODE in that FAQ entry). However, for maximum row size calculations, the maximum size per column uses the maximum byte-size, which is calculated as (character length) * (max bytes per character), which is 4 for UTF8, 3 for UNICODE_FSS. Firebird doesn't support a UTF16 character set. – Mark Rotteveel Mar 30 '23 at 11:32

0 Answers0