コード例 #1
0
        public SelectStatement Join(string foreignKeyColumn, string alias)
        {
            /*
             * usage: .CreateSelect("core.Product", "p").Join("p.ProductTypeId", "pt")
             *
             * joins the foreign key p.ProductTypeId to the referenced object on its primary key
             */
            GetJoinAndColumnDef(foreignKeyColumn, (parentJoin, parentColumnDef) =>
            {
                ObjectDef objectDef = parentColumnDef.ReferencedObject;
                ColumnDef columnDef = objectDef.PrimayKeyColumn;

                Join join = new Join(parentJoin, parentColumnDef, columnDef, alias);

                Joins.Add(join);
            });

            return(this);
        }
コード例 #2
0
        public SelectStatement Join(string parentAlias, string primaryObject, string alias)
        {
            /*
             * usage: .CreateSelect("core.ProductType", "pt").Join("pt", "core.Product", "p")
             *
             * joins the primary key of pt.ProductTypeId to the foreigh key of core.Product that references core.ProductType
             */
            Join parentJoin = Joins.Single(item => item.Alias == parentAlias);

            ObjectDef objectDef = _builder.ObjectDefs.Single(item => item.FullName == primaryObject);

            ColumnDef columnDef = _builder.ColumnDefs.Single(item => item.ObjectDef == objectDef && item.ReferencedObject == parentJoin.ObjectDef);

            Join join = new Join(parentJoin, parentJoin.ObjectDef.PrimayKeyColumn, columnDef, alias);

            Joins.Add(join);

            return(this);
        }