本文整理汇总了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 -------------------------
}
示例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);
}
示例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());
}
示例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]);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
示例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);
}
示例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());
}
示例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 -------------------------
}
示例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);
}