实体框架核心postgresql数组类型映射不起作用 [英] Entity Framework Core postgresql Array Type Mapping not working

查看:92
本文介绍了实体框架核心postgresql数组类型映射不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题,也许这是我遗漏的东西,但是我有以下LINQ Lambda查询:

I have a strange problem, maybe it is something that I'm missing out, but I have the following LINQ Lambda query:

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();

根据这篇文章,应将其翻译为:

According to this article, this should be translated to this:

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

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

区别在于应该在的位置 d.id = ANY(s.control_area) TRUE = FALSE

The difference is where it should be d.id = ANY(s.control_area) it is TRUE = FALSE

有人能告诉我我在做什么错吗?

Can anyone tell me what am I doing wrong?

谢谢,

Julian Dimitrov

Julian Dimitrov

推荐答案

我能够解决我的问题。它在问题中。

I was able to solve my problem. It is in this issue.

基本上:


它在实体配置中。 Device 实体中的 ControlArea 属性的类型为 List< long> 。当我将其更改为 long [] (长数组)时,它起作用了!

It was in the entities configuration. The ControlArea property in the Device entity was of type List<long>. When I changed it to long[] (long array) it worked!

这篇关于实体框架核心postgresql数组类型映射不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆