pg数据库使用 SqlFunc.MappingColumn 自定义扩展类型错误 返回
SqlSugar
处理完成
2
168
OsmondDeng 发布于2024/4/2
悬赏:0 飞吻
以下是我的代码
Db.Queryable<SysMenu>() .Where(s => !s.IsDeleted && (s.PageType == 0 || s.PageType == model.PageType)) .LeftJoin<SysRoleMenu>((m, srm) => m.Id == srm.MenuId && srm.RoleId == model.RoleId && !srm.IsDeleted) .LeftJoin<SysButton>((m, srm, b) => m.Id == b.MenuId && !b.IsDeleted) .GroupBy((m, srm, b) => new { m.ParentId, m.ParentModule, m.Code, m.Id, m.DisplayName, srm.RoleId }) .Select((m, srm, b) => new AuthorizationMenuModel { ParentId = m.ParentId, ParentModule = m.ParentModule, Code = m.Code, Id = m.Id, DisplayName = m.DisplayName, IsCheck = !string.IsNullOrEmpty(srm.RoleId), ButtonCount = SqlFunc.AggregateCount(b.Id), ButtonIds = SqlFunc.MappingColumn<string[]>(" ARRAY_AGG ( DISTINCT b.ID ) ") }).ToSqlString();
但是最后生成出来的sql语句并不是有效的语句
SELECT "m"."parent_id" AS "parentid", "m"."parent_module" AS "parentmodule", "m"."code" AS "code", "m"."id" AS "id", "m"."display_name" AS "displayname", ( CASE WHEN NOT ( "srm"."role_id" IS NULL OR "srm"."role_id" = '' ) THEN 1 ELSE 0 END ) AS "ischeck", COUNT ( "b"."id" ) AS "buttoncount", ARRAY_AGG ( DISTINCT b.ID ).LENGTH AS " array_agg ( distinct b.id ) .string[].length", ARRAY_AGG ( DISTINCT b.ID ).LongLength AS " array_agg ( distinct b.id ) .string[].longlength", ARRAY_AGG ( DISTINCT b.ID ).RANK AS " array_agg ( distinct b.id ) .string[].rank", ARRAY_AGG ( DISTINCT b.ID ).IsReadOnly AS " array_agg ( distinct b.id ) .string[].isreadonly", ARRAY_AGG ( DISTINCT b.ID ).IsFixedSize AS " array_agg ( distinct b.id ) .string[].isfixedsize", ARRAY_AGG ( DISTINCT b.ID ).IsSynchronized AS " array_agg ( distinct b.id ) .string[].issynchronized" FROM ( SELECT * FROM ( SELECT "code", "display_name", "index_page", "is_module", "business_scope", "icon", "sort", "url_address", "remark", "server_url", "page_type", "parent_module", "parent_id", "component", "is_leaf", "is_line", "is_enabled", "no_cache", "menu_type", "is_outsidethechain", "outsidethechain_open_method", "id", "create_date", "create_userid", "create_username", "modify_userid", "modify_username", "modify_date", "is_deleted" FROM "sys_menu" WHERE ( NOT ( "is_deleted" = TRUE ) AND ( ( "page_type" = 0 ) OR ( "page_type" = 1 ) ) ) ) MergeTable ) "m" LEFT JOIN "sys_role_menu" "srm" ON ( ( ( "m"."id" = "srm"."menu_id" ) AND ( "srm"."role_id" = N '1773579117074190336' ) ) AND NOT ( "srm"."is_deleted" = TRUE ) ) LEFT JOIN "sys_button" "b" ON ( ( "m"."id" = "b"."menu_id" ) AND NOT ( "b"."is_deleted" = TRUE ) ) GROUP BY "m"."parent_id", "m"."parent_module", "m"."code", "m"."id", "m"."display_name", "srm"."role_id"
热忱回答(2)
-
fate sta VIP02024/4/2
SqlFunc.MappingColumn
目前 只支持简单类型不支持 string[] 我支持一下
0 回复 -
fate sta VIP02024/4/3
SqlSugarCore 5.1.4.150-preview03
勾一下预览已修复
0 回复