OutSystems Entity Internals
Espace join Entity
on Espace.Id = Entity.Espace_Id
Entity join Etity_Attr
on Entity.Id = Etity_Attr.Entity_Id
where Espace.Name = @ModuleNameThatContainsTheEnity
Espace join Entity
on Espace.Id = Entity.Espace_Id
Entity join Etity_Attr
on Entity.Id = Etity_Attr.Entity_Id
where
Espace.Name = @ModuleNameThatContainsTheEnity and
Enity.Name = @Entity_Name
with x as (
select
{Espace}.[Name] EspaceName,
{Espace}.[id] EspaceId,
{Espace}.[ss_key] EspaceSsKey,
{Entity}.[Name] EntityName,
{Entity}.[id] EntityId,
{Entity}.[ss_key] EntitySsKey,
{Entity}.[PrimaryKey_SS_Key] EntityPrimaryKeySsKey,
{Entity_Attr}.[Name] EntityAttrName,
{Entity_Attr}.[id] EntityAttrId,
{Entity_Attr}.[ss_key] EntityAttrSsKey,
{entity_Attr}.[Type] EntityAttrType
from {Espace}
inner join {Entity}
on {Entity}.[Espace_Id] = {Espace}.[Id]
inner join {Entity_Attr}
on {Entity_Attr}.[Entity_Id] = {Entity}.[id]
)
select
p.EspaceName || '.[' || p.EntityName || '].{' || p.EntityAttrName || '}' ForeignKey,
f.EspaceName || '.[' || f.EntityName || '].{' || f.EntityAttrName || '}' PrimaryKey
from x p, x f
where p.EntityAttrType = 'bt' || f.EspaceSsKey || '*' || f.EntitySsKey
and f.EntityAttrSsKey = f.EntityPrimaryKeySsKey