title: Malformed string exception Firebird + linq
body: <p>I try to execute simple LINQ query like this </p>
  
  <pre><code>var images = context.IMAGES;
  images = from img in images
           join imt in context.IMAGE_TAG on img.ID equals imt.ID_IMAGE
           where tags.Any(tag =&gt; imt.TAGS.NAME.Contains(tag))
           select img;
  </code></pre>
  
  <p>When firebird adapter translates to SQL query it tries to cast my cyrillic text to utf-8 like this</p>
  
  <pre><code>CAST(_UTF8'тату' AS VARCHAR(8191)) AS "C1"
  </code></pre>
  
  <p>and I get </p>
  
  <blockquote>
    <p>"Dynamic SQL Error\r\nSQL error code = -104\r\nMalformed string"</p>
  </blockquote>
  
  <p><strong>UPDATED:</strong>
  Generated query:</p>
  
  <pre><code>SELECT "C"."ID" AS "ID", "C"."GUID" AS "GUID", "C"."EXT" AS "EXT", "C"."ID_USER" AS "ID_USER", "C"."IS_NEW" AS "IS_NEW"FROM  "IMAGES" AS "C"INNER JOIN "IMAGE_TAG" AS "D" ON "C"."ID" = "D"."ID_IMAGE"WHERE  EXISTS (SELECT     1 AS "C1"   FROM   (SELECT      CAST(_UTF8'тату' AS VARCHAR(8191)) AS "C1"      FROM  ( SELECT 1 AS X FROM RDB$DATABASE) AS "G" UNION ALL       SELECT      CAST(_UTF8'tatuir' AS VARCHAR(8191)) AS "C1"        FROM  ( SELECT 1 AS X FROM RDB$DATABASE) AS "H") AS "I" LEFT OUTER JOIN  (SELECT        "K"."ID" AS "ID",       "K"."NAME" AS "NAME"        
  FROM "TAGS" AS "K"      
  WHERE "D"."ID_TAG" = "K"."ID" ) AS "L" ON CAST(1 AS SMALLINT) = CAST(1 AS SMALLINT) WHERE (POSITION("I"."C1", "L"."NAME")) &gt; 0)
  </code></pre>
  
  <p>Simple table for tags:</p>
  
  <pre><code>CREATE TABLE TAGS (
      ID    INTEGER NOT NULL,
      NAME  VARCHAR(50) NOT NULL
  );
  </code></pre>
  
  <p>"NAME" column has WIN1251 charset.</p>