当前位置: 首页>>代码示例>>C#>>正文


C# Source.JoinToSource方法代码示例

本文整理汇总了C#中Source.JoinToSource方法的典型用法代码示例。如果您正苦于以下问题:C# Source.JoinToSource方法的具体用法?C# Source.JoinToSource怎么用?C# Source.JoinToSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Source的用法示例。


在下文中一共展示了Source.JoinToSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestToString_WithJoin

        public void TestToString_WithJoin()
        {
            //---------------Set up test pack-------------------
            string sourceName = TestUtil.GetRandomString();
            Source source = new Source(sourceName);
            string subSourceName = TestUtil.GetRandomString();
            source.JoinToSource(new Source(subSourceName));
            //---------------Execute Test ----------------------
            string sourceToString = source.ToString();

            //---------------Test Result -----------------------
            string expectedSourceToString = string.Format("{0}.{1}", sourceName, subSourceName);
            StringAssert.AreEqualIgnoringCase(expectedSourceToString, sourceToString);
            //---------------Tear Down -------------------------
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:15,代码来源:TestSource.cs

示例2: TestSetCriteria_AddsJoins

        public void TestSetCriteria_AddsJoins()
        {
            //---------------Set up test pack-------------------
            var selectQuery = new SelectQuery();
            const string sourceName = "mysource";
            selectQuery.Source = new Source(sourceName);
            var fieldSource = new Source(sourceName);
            var expectedSourceName = TestUtil.GetRandomString();
            fieldSource.JoinToSource(new Source(expectedSourceName));
            var field = new QueryField("testfield", "testfield", fieldSource);
            var criteria = new Criteria(field, Criteria.ComparisonOp.Equals, "value");

            //---------------Execute Test ----------------------
            selectQuery.Criteria = criteria;
            //---------------Test Result -----------------------
            Assert.AreEqual(1, selectQuery.Source.Joins.Count);
            Assert.AreEqual(selectQuery.Source, selectQuery.Source.Joins[0].FromSource);
            Assert.AreEqual(expectedSourceName, selectQuery.Source.Joins[0].ToSource.Name);
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:19,代码来源:TestSelectQuery.cs

示例3: Test_CreateSQL_ShouldUseAliasesInJoins

        public void Test_CreateSQL_ShouldUseAliasesInJoins()
        {
            //---------------Set up test pack-------------------
            SelectQuery selectQuery = new SelectQuery();
            var mysource = new Source("mysource");
            selectQuery.Source = mysource;

            QueryField fieldOnMySource = new QueryField("testfield", "testfield", mysource);

            Source joinedTableSource = new Source("mysource");
            joinedTableSource.JoinToSource(new Source("myjoinedtosource"));

            QueryField fieldOnJoinedTableSource = new QueryField("testfield", "testfield", joinedTableSource);

            joinedTableSource.Joins[0].JoinFields.Add(new Source.Join.JoinField(fieldOnMySource, fieldOnJoinedTableSource));
            selectQuery.Fields.Add(fieldOnMySource.FieldName, fieldOnMySource);

            selectQuery.Criteria = new Criteria(fieldOnJoinedTableSource, Criteria.ComparisonOp.Equals, "myvalue");
            SelectQueryDB query = new SelectQueryDB(selectQuery, DatabaseConnection.CurrentConnection);
            SqlFormatter sqlFormatter = new SqlFormatter("[", "]", "", "LIMIT");
            //---------------Execute Test ----------------------
            ISqlStatement statement = query.CreateSqlStatement(sqlFormatter);
            //---------------Test Result -----------------------
            StringAssert.AreEqualIgnoringCase(
                "SELECT a1.[testfield] FROM ([mysource] a1 " + 
                "JOIN [myjoinedtosource] a2 on a1.[testfield] = a2.[testfield]) " + 
                "WHERE a2.[testfield] = ?Param0", statement.Statement.ToString());
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:28,代码来源:TestSelectQueryDB.cs

示例4: Test_Clone

 public void Test_Clone()
 {
     //---------------Set up test pack-------------------
     string sourceName = "SourceName";
     string entityName = "EntityName";
     Source source = new Source(sourceName, entityName);
     Source joinSource = new Source("JoinSource");
     source.JoinToSource(joinSource);
     //---------------Execute Test ----------------------
     Source cloneOfSource = source.Clone();
     //---------------Test Result -----------------------
     Assert.AreNotSame(source, cloneOfSource);
     Assert.AreEqual(source.Name, cloneOfSource.Name);
     Assert.AreEqual(source.EntityName, cloneOfSource.EntityName);
     Assert.AreEqual(source.Joins.Count, cloneOfSource.Joins.Count);
     Assert.AreNotSame(source.Joins[0], cloneOfSource.Joins[0]);
 }
开发者ID:kevinbosman,项目名称:habanero,代码行数:17,代码来源:TestSource.cs

示例5: Test_MergeTwoSources_CheckThatSecondMergeDoesntAffectSourceOfFirstField

        public void Test_MergeTwoSources_CheckThatSecondMergeDoesntAffectSourceOfFirstField()
        {
            //---------------Set up test pack-------------------
            Source originalSource = new Source("Allegation", "Allegation");

            Source receivedDateSource1 = new Source("Allegation");
            receivedDateSource1.JoinToSource(new Source("Request"));

            Source institutionSource = new Source("Allegation");
            Source reqSource = new Source("Request");
            reqSource.JoinToSource(new Source("Institution"));
            institutionSource.JoinToSource(reqSource);

            QueryField receivedDate1Field = new QueryField("ReceivedDate", "ReceivedDate", receivedDateSource1);
            QueryField institutionField = new QueryField("Name", "Name", institutionSource);

            originalSource.MergeWith(receivedDate1Field.Source);

            //---------------Assert preconditions---------------
            Assert.AreEqual("Allegation.Request", receivedDate1Field.Source.ToString());
            Assert.AreEqual("Allegation.Request.Institution", institutionField.Source.ToString());
            //---------------Execute Test ----------------------
            originalSource.MergeWith(institutionField.Source);
            //---------------Test Result -----------------------
            Assert.AreEqual("Allegation.Request", receivedDate1Field.Source.ToString());
            Assert.AreEqual("Allegation.Request.Institution", institutionField.Source.ToString());
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:27,代码来源:TestSource.cs

示例6: TestChildSourceLeaf

 public void TestChildSourceLeaf()
 {
     //-------------Setup Test Pack ------------------
     Source source = new Source("MySource", "MY_TABLE");
     Source joinSource = new Source("JoinSource", "MY_JOINED_TABLE");
     Source joinSource2 = new Source("JoinSource2", "MY_JOINED_TABLE2");
     joinSource.JoinToSource(joinSource2);
     source.JoinToSource(joinSource);
     //-------------Execute test ---------------------
     Source childSourceLeaf = source.ChildSourceLeaf;
     //-------------Test Result ----------------------
     Assert.AreEqual(joinSource2, childSourceLeaf);
 }
开发者ID:kevinbosman,项目名称:habanero,代码行数:13,代码来源:TestSource.cs

示例7: TestMergeWith_EqualSource_DifferentChildSources

        public void TestMergeWith_EqualSource_DifferentChildSources()
        {
            //-------------Setup Test Pack ------------------
            Source originalSource = new Source("FromSource", "FromSourceEntity");
            originalSource.JoinToSource(new Source("ToSource", "ToSourceEntity"));
            Source otherSource = new Source("FromSource", "FromSourceEntity");
            Source childSource = new Source("ToSource", "ToSourceEntity");
            childSource.JoinToSource(new Source("GrandchildSource", "GrandchildSourceEntity"));
            otherSource.JoinToSource(childSource);
            //-------------Test Pre-conditions --------------

            //-------------Execute test ---------------------
            originalSource.MergeWith(otherSource);
            //-------------Test Result ----------------------
            Assert.AreEqual(1, originalSource.Joins.Count);
            Assert.AreEqual(1, originalSource.ChildSource.Joins.Count);
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:17,代码来源:TestSource.cs

示例8: TestMergeWith_IncludesJoinFields

        public void TestMergeWith_IncludesJoinFields()
        {
            //-------------Setup Test Pack ------------------
            Source originalSource = new Source("FromSource", "FromSourceEntity");
            Source otherSource = new Source("FromSource", "FromSourceEntity");
            Source childSource = new Source("ToSource", "ToSourceEntity");
            otherSource.JoinToSource(childSource);
            QueryField field1 = new QueryField("Prop1", "Prop1Field", otherSource);
            QueryField field2 = new QueryField("Prop1", "Prop1Field", childSource);
            otherSource.Joins[0].JoinFields.Add(new Source.Join.JoinField(field1, field2));

            //-------------Execute test ---------------------
            originalSource.MergeWith(otherSource);

            //-------------Test Result ----------------------
            Assert.AreEqual(1, originalSource.Joins.Count);
            Assert.AreEqual(1, originalSource.Joins[0].JoinFields.Count);
            Assert.AreEqual(field1, originalSource.Joins[0].JoinFields[0].FromField);
            Assert.AreEqual(field2, originalSource.Joins[0].JoinFields[0].ToField);
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:20,代码来源:TestSource.cs

示例9: TestMergeWith_TwoLevels

        public void TestMergeWith_TwoLevels()
        {
            //-------------Setup Test Pack ------------------
            Source originalSource = new Source("FromSource", "FromSourceEntity");
            Source otherSource = new Source("FromSource", "FromSourceEntity");
            Source childSource = new Source("ChildSource", "ChildSourceEntity");
            Source grandchildSource = new Source("GrandChildSource", "GrandchildSourceEntity");
            childSource.JoinToSource(grandchildSource);
            otherSource.JoinToSource(childSource);

            //-------------Execute test ---------------------
            originalSource.MergeWith(otherSource);

            //-------------Test Result ----------------------
            Assert.AreSame(grandchildSource.ToString(), originalSource.ChildSource.ChildSource.ToString());
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:16,代码来源:TestSource.cs

示例10: TestMergeWith_Simple

        public void TestMergeWith_Simple()
        {
            //-------------Setup Test Pack ------------------
            Source fromSource = new Source("FromSource", "FromSourceEntity");
            Source otherSource = new Source("FromSource", "FromSourceEntity");
            otherSource.JoinToSource(new Source("ToSource", "ToSourceEntity"));

            //-------------Execute test ---------------------
            fromSource.MergeWith(otherSource);
            //-------------Test Result ----------------------
            Assert.AreSame(fromSource.ChildSource.ToString(), otherSource.ChildSource.ToString());
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:12,代码来源:TestSource.cs

示例11: TestMergeWith_EmptySource

        public void TestMergeWith_EmptySource()
        {
            //-------------Setup Test Pack ------------------
            Source fromSource = new Source("FromSource", "FromSourceEntity");
            Source otherSource = new Source("", "FromSourceEntity");
            otherSource.JoinToSource(new Source("ToSource", "ToSourceEntity"));

            //-------------Execute test ---------------------
            fromSource.MergeWith(otherSource);
            //-------------Test Result ----------------------
            Assert.AreEqual(0, fromSource.Joins.Count);
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:12,代码来源:TestSource.cs

示例12: TestJoinToSource_NullSource

        public void TestJoinToSource_NullSource()
        {
            //---------------Set up test pack-------------------
            Source fromSource = new Source("FromSource", "FromSourceEntity");

            //---------------Execute Test ----------------------
            fromSource.JoinToSource(null);

            //---------------Test Result -----------------------
            Assert.AreEqual(0, fromSource.Joins.Count);
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:11,代码来源:TestSource.cs

示例13: TestJoinToSource_AlreadyJoined

        public void TestJoinToSource_AlreadyJoined()
        {
            //---------------Set up test pack-------------------
            Source fromSource = new Source("FromSource", "FromSourceEntity");
            Source toSource = new Source("ToSource", "ToSourceEntity");
            Source toSource2 = new Source("ToSource", "ToSourceEntity");
            fromSource.JoinToSource(toSource);

            //---------------Execute Test ----------------------
            fromSource.JoinToSource(toSource2);

            //---------------Test Result -----------------------
            Assert.AreEqual(1, fromSource.Joins.Count);
            Assert.AreEqual(fromSource.ToString(), fromSource.Joins[0].FromSource.ToString());
            Assert.AreEqual(toSource.ToString(), fromSource.Joins[0].ToSource.ToString());
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:16,代码来源:TestSource.cs

示例14: TestJoinToSource

        public void TestJoinToSource()
        {
            //---------------Set up test pack-------------------
            var fromSource = new Source("FromSource", "FromSourceEntity");
            var toSource = new Source("ToSource", "ToSourceEntity");

            //---------------Execute Test ----------------------
            fromSource.JoinToSource(toSource);

            //---------------Test Result -----------------------

            Assert.AreEqual(1, fromSource.Joins.Count);
            Assert.AreEqual(fromSource.ToString(), fromSource.Joins[0].FromSource.ToString());
            Assert.AreEqual(toSource.ToString(), fromSource.Joins[0].ToSource.ToString());
            //---------------Tear Down -------------------------
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:16,代码来源:TestSource.cs

示例15: TestSetOrderCriteria_AddsJoinToSource

        public void TestSetOrderCriteria_AddsJoinToSource()
        {
            //---------------Set up test pack-------------------
            var selectQuery = new SelectQuery();
            const string sourceName = "mysource";
            selectQuery.Source = new Source(sourceName);
            var orderSource = new Source(sourceName);
            var expectedSourceName = TestUtil.GetRandomString();
            orderSource.JoinToSource(new Source(expectedSourceName));
            var orderOrderCriteriaField = new OrderCriteriaField("testfield", "testfield", orderSource, SortDirection.Ascending);
            var orderCriteria = new OrderCriteria().Add(orderOrderCriteriaField);

            //---------------Execute Test ----------------------
            selectQuery.OrderCriteria = orderCriteria;
            //---------------Test Result -----------------------
            Assert.AreEqual(1, selectQuery.Source.Joins.Count);
            Assert.AreEqual(selectQuery.Source, selectQuery.Source.Joins[0].FromSource);
            Assert.AreEqual(expectedSourceName, selectQuery.Source.Joins[0].ToSource.Name);
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:19,代码来源:TestSelectQuery.cs


注:本文中的Source.JoinToSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。