Le mappage de type de tableau postgresql Entity Framework Core ne fonctionne pas

Sep 24 2020

J'ai un problème étrange, c'est peut-être quelque chose que je rate, mais j'ai la requête LINQ Lambda suivante:

var ss = ctx.ShipZones.SelectMany(
                z => ctx.ShipDecks,
                (z, d) =>
                    new
                    {
                        Zone = z.ZIndex,
                        Deck = d.DIndex,
                        Value = ctx.Tags
                            .AsExpandable()
                            .Include(s => s.TagSettings.Device.System)
                            .Where(s =>
                                 s.TagSettings.TagTypeId == 171
                                 && s.TagSettings.Device.System.Id == z.Id
                                 && s.TagSettings.Device.ControlArea.Contains(d.Id)

                                    )
                            .Average(s => s.Value)

                    }
                ).ToList();

Selon cet article, cela devrait se traduire par ceci:

SELECT z.z_index AS "Zone", d.d_index AS "Deck", (
  SELECT AVG(t.value)
  FROM tags_current_data AS t
  INNER JOIN tags_settings AS t0 ON t.tag_id = t0.id
  INNER JOIN systems_devices AS s ON t0.device_id = s.id
  INNER JOIN systems AS s0 ON s.system_id = s0.id
  WHERE ((t0.tag_type_id = 171) AND (s0.id = z.id)) AND (d.id = ANY(s.control_area))) AS "Value"
FROM zones AS z
CROSS JOIN decks AS d

Mais d'une manière ou d'une autre, la requête traduite est comme ceci:

SELECT z.z_index AS "Zone", d.d_index AS "Deck", (
  SELECT AVG(t.value)
  FROM tags_current_data AS t
  INNER JOIN tags_settings AS t0 ON t.tag_id = t0.id
  INNER JOIN systems_devices AS s ON t0.device_id = s.id
  INNER JOIN systems AS s0 ON s.system_id = s0.id
  WHERE ((t0.tag_type_id = 171) AND (s0.id = z.id)) AND (TRUE = FALSE)) AS "Value"
FROM zones AS z
CROSS JOIN decks AS d

La différence est là où ça devrait être d.id = ANY(s.control_area)c'estTRUE = FALSE

Quelqu'un peut-il me dire ce que je fais de mal?

Merci d'avance,

Julian Dimitrov

Réponses

Julian Sep 25 2020 at 08:36

J'ai pu résoudre mon problème. C'est dans ce numéro.

Fondamentalement:

C'était dans la configuration des entités. La ControlAreapropriété de l' Deviceentité était de type List<long>. Quand je l'ai changé en long[](long tableau), cela a fonctionné!