The model:
[Table("RECIPE")]
public class Recipe
{
[Key, Column("ID"), DatabaseGenerated(DatabaseGeneratedOption.None), Required]
public int ID { get; set; }
[Column("NAME")]
public string Name { get; set; }
public virtual ICollection<Ingredient> Ingredients { get; set; }
}
[Table("INGREDIENTS")]
public class Ingredient
{
[Key, Column("ID"), DatabaseGenerated(DatabaseGeneratedOption.None)]
public int ID { get; set; }
[Column("RECIPE"), Required]
public int RecipeID { get; set; }
[ForeignKey("RecipeID")]
public virtual Recipe Recipe { get; set; }
[Column("NAME")]
public string Name { get; set; }
}
public class RecipeCtx : DbContext
{
public DbSet<Recipe> Recipes { get; set; }
public DbSet<Ingredient> Ingredients { get; set; }
}
The Controller:
public ViewResult Index()
{
var ingredients = (from ing in db.Ingredients.Include(c => c.Recipe) orderby ing.ID select ing)
.Skip(20)
.Take(20)
.ToList();
return View(ingredients);
}
The generated query:
SELECT
"Limit1"."Extent1"."ID" AS "ID",
"Limit1"."Extent1"."RECIPE" AS "RECIPE",
"Limit1"."Extent1"."NAME" AS "NAME",
"Limit1"."Extent2"."ID" AS "ID1",
"Limit1"."Extent2"."NAME" AS "NAME1"
FROM ( SELECT FIRST (20) SKIP (20) "Extent1"."ID" AS "ID1", "Extent1"."RECIPE" AS "RECIPE", "Extent1"."NAME" AS "NAME1", "Extent2"."ID" AS "ID2", "Extent2"."NAME" AS "NAME2"
FROM "INGREDIENTS" AS "Extent1"
INNER JOIN "RECIPE" AS "Extent2" ON "Extent1"."RECIPE" = "Extent2"."ID"
ORDER BY "Extent1"."ID" ASC
) AS "Limit1"
The exception:
{"An error occurred while executing the command definition. See the inner exception for details."}
{"Dynamic SQL Error\r\nSQL error code = -104\r\nToken unknown - line 2, column 19\r\n."}
If I remove the skip it works fine.
i’m using:
Firebird Server Version 2.5.1.26351 (the latest version)
FirebirdClient - ADO.NET Data Provider version 2.7.0.0 (the latest version)
What can I do to get around this?
It’s a bug in provider. Report it to tracker.firebirdsql.org.