Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 1.95 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Entity Framework produces invalid Firebird query when using INCLUDE and SKIP together
  2. [Table("RECIPE")]
  3. public class Recipe
  4. {
  5.  
  6.     [Key, Column("ID"), DatabaseGenerated(DatabaseGeneratedOption.None), Required]
  7.     public int ID { get; set; }
  8.  
  9.     [Column("NAME")]
  10.     public string Name { get; set; }
  11.  
  12.  
  13.     public virtual ICollection<Ingredient> Ingredients { get; set; }
  14.  
  15. }
  16.  
  17. [Table("INGREDIENTS")]
  18. public class Ingredient
  19. {
  20.  
  21.     [Key, Column("ID"), DatabaseGenerated(DatabaseGeneratedOption.None)]
  22.     public int ID { get; set; }
  23.  
  24.     [Column("RECIPE"), Required]
  25.     public int RecipeID { get; set; }
  26.  
  27.     [ForeignKey("RecipeID")]
  28.     public virtual Recipe Recipe { get; set; }
  29.  
  30.     [Column("NAME")]
  31.     public string Name { get; set; }
  32.  
  33. }
  34.  
  35.  
  36. public class RecipeCtx : DbContext
  37. {
  38.  
  39.     public DbSet<Recipe> Recipes { get; set; }
  40.     public DbSet<Ingredient> Ingredients { get; set; }
  41.  
  42.  
  43. }
  44.        
  45. public ViewResult Index()
  46.     {
  47.  
  48.         var ingredients = (from ing in db.Ingredients.Include(c => c.Recipe) orderby ing.ID select ing)
  49.             .Skip(20)
  50.             .Take(20)
  51.             .ToList();
  52.  
  53.         return View(ingredients);
  54.  
  55.     }
  56.        
  57. SELECT
  58. "Limit1"."Extent1"."ID" AS "ID",
  59. "Limit1"."Extent1"."RECIPE" AS "RECIPE",
  60. "Limit1"."Extent1"."NAME" AS "NAME",
  61. "Limit1"."Extent2"."ID" AS "ID1",
  62. "Limit1"."Extent2"."NAME" AS "NAME1"
  63. 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"
  64.     FROM  "INGREDIENTS" AS "Extent1"
  65.     INNER JOIN "RECIPE" AS "Extent2" ON "Extent1"."RECIPE" = "Extent2"."ID"
  66.     ORDER BY "Extent1"."ID" ASC
  67. )  AS "Limit1"
  68.        
  69. {"An error occurred while executing the command definition. See the inner exception for details."}
  70.  
  71. {"Dynamic SQL ErrorrnSQL error code = -104rnToken unknown - line 2, column 19rn."}
  72.        
  73. Firebird Server Version 2.5.1.26351 (the latest version)
  74.  
  75. FirebirdClient - ADO.NET Data Provider version 2.7.0.0 (the latest version)