Exemplo n.º 1
0
            protected override void Test(IOrganizationService service)
            {
                var qryExpression = new QueryExpressionBuilder <Account>()
                                    .With.DatabaseLock(false)
                                    .With.RecordLimit(10)
                                    .Select(cols => new { cols.AccountNumber, cols.Name })
                                    .LeftJoin <Contact>("primarycontactid", "contactid", c => c
                                                        .InnerJoin <SystemUser>("ownerid", "systemuserid", u => u
                                                                                .With.Alias("owner")
                                                                                .Select(cols => new { cols.SystemUserId })))
                                    .Build();

                var parsed = qryExpression.ToReadableText();

                var linkEntity = qryExpression.LinkEntities[0];

                linkEntity = linkEntity.LinkEntities[0];

                Assert.AreEqual(JoinOperator.Inner, linkEntity.JoinOperator);
                Assert.AreEqual("contact", linkEntity.LinkFromEntityName);
                Assert.AreEqual("systemuser", linkEntity.LinkToEntityName);
                Assert.AreEqual("ownerid", linkEntity.LinkFromAttributeName);
                Assert.AreEqual("systemuserid", linkEntity.LinkToAttributeName);
                Assert.AreEqual("owner", linkEntity.EntityAlias);
            }