Example #1
0
        private IDictionary <string, object>[] GetLinkedBeanRowsEx(string kind, LinkScenario ls)
        {
            // SELECT * is not an option here, because one Primary Key column is
            // not delivered. So the projection has to be put together "manually"
            // and checked if all Primary keys included.

            var beanProjection = string.Join(", ",
                                             Api.GetKindColumns(kind).Select(c => $"bean.{c} AS bean_{c}"));

            if (!beanProjection.Contains($"bean.{ls.LinkedKindPkName}"))
            {
                beanProjection = $"bean.{ls.LinkedKindPkName} AS bean_{ls.LinkedKindPkName}, " + beanProjection;
            }

            var linkProjection = string.Join(", ",
                                             Api.GetKindColumns(ls.LinkKind).Select(c => $"link.{c} AS link_{c}"));

            if (!linkProjection.Contains($"link.{ls.LinkKindPkName}"))
            {
                linkProjection = $"link.{ls.LinkKindPkName} AS link_{ls.LinkKindPkName}, " + linkProjection;
            }

            return(Api.Rows(true,
                            CreateLinkQuery($"{beanProjection}, {linkProjection}", ls), ls.LinkingKindPkValue));
        }