本文整理汇总了C#中System.Reference.Walk方法的典型用法代码示例。如果您正苦于以下问题:C# Reference.Walk方法的具体用法?C# Reference.Walk怎么用?C# Reference.Walk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reference
的用法示例。
在下文中一共展示了Reference.Walk方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SerializeBooleanField
public void SerializeBooleanField()
{
var idAndBoolean = new List<FieldConfig>
{
new FieldConfig("Id", null),
new FieldConfig("IsBaz", FieldType.Boolean)
};
var foobar = new OracularTable ("Foobar", null, null, idAndBoolean);
var tables = new List<OracularTable>
{
foobar
};
var specs = new List<OracularSpec> ();
var config = new OracularConfig (tables, specs);
var foobarReference = new Reference (new [] { "Foobar", "IsBaz" });
var sql = foobarReference.Walk (new Sqlizer (foobar, config));
Assert.AreEqual ("[Foobar].[IsBaz] = 1", sql);
}
示例2: ExpectReferenceRootToBeInTables
public void ExpectReferenceRootToBeInTables()
{
var justAnId = new List<FieldConfig>
{
new FieldConfig("Id", null)
};
var tables = new List<OracularTable>
{
new OracularTable("Other", null, null, justAnId),
new OracularTable("Tables", null, null, justAnId)
};
var config = new OracularConfig (tables, new List<OracularSpec> ());
var checker = new RefChecker (config);
var reference = new Reference (new []{ "Foobar" });
var initial = new []{ "Other", "Tables" };
var ex = Assert.Throws<RefCheckException> (() => reference.Walk (checker, initial));
Assert.That (JOIN_RE.IsMatch (ex.Message));
}
示例3: CheckReferenceRoot
public void CheckReferenceRoot()
{
var justAnId = new List<FieldConfig>
{
new FieldConfig("Id", null)
};
var tables = new List<OracularTable>
{
new OracularTable("Foobar", null, null, justAnId)
};
var config = new OracularConfig (tables, new List<OracularSpec> ());
var checker = new RefChecker (config);
var reference = new Reference (new []{ "Foobar" });
var initial = new []{ "Foobar" };
var result = reference.Walk (checker, initial);
Assert.AreEqual (1, result.Length);
Assert.Contains ("Foobar", result);
}
示例4: SerializeFieldOnAlias
public void SerializeFieldOnAlias()
{
var foobar = foobarTable ();
var tables = new List<OracularTable>
{
foobar
};
var specs = new List<OracularSpec> ();
var config = new OracularConfig (tables, specs);
var foobarReference = new Reference (new [] { "Foobar", "Id" });
var sql = foobarReference.Walk (new Sqlizer (foobar, config, "Alias"));
Assert.AreEqual ("[Alias].[Id]", sql);
}
示例5: SerializeTableName
public void SerializeTableName()
{
var foobar = foobarTable ();
var tables = new List<OracularTable>
{
foobar
};
var specs = new List<OracularSpec> ();
var config = new OracularConfig (tables, specs);
var foobarReference = new Reference (new [] { "Foobar" });
var sql = foobarReference.Walk (new Sqlizer (foobar, config));
Assert.AreEqual ("[Foobar]", sql);
}
示例6: SerializeParentTable
public void SerializeParentTable()
{
var justAnId = new List<FieldConfig>
{
new FieldConfig("Id", null)
};
var idAndBarId = new List<FieldConfig>
{
new FieldConfig("Id", null),
new FieldConfig("BarId", null)
};
var barRelationship = new List<ParentConfig>
{
new ParentConfig("Bar", null, null)
};
var foo = new OracularTable ("Foo", null, barRelationship, idAndBarId);
var tables = new List<OracularTable>
{
foo,
new OracularTable("Bar", null, null, justAnId)
};
var specs = new List<OracularSpec> ();
var config = new OracularConfig (tables, specs);
var foobarReference = new Reference (new [] { "Foo", "Bar" });
var builder = new Sqlizer (foo, config);
var sql = foobarReference.Walk (builder);
Assert.AreEqual ("[Foo.Bar]", sql);
Assert.AreEqual (1, builder.JoinTables.Count ());
var joinClause = builder.JoinTables.First();
Assert.AreEqual ("INNER JOIN [Bar] [Foo.Bar] ON [Foo.Bar].[Id] = [Foo].[BarId]", joinClause);
}
示例7: SerializeGrandparentTableOnAlias
public void SerializeGrandparentTableOnAlias()
{
var justAnId = new List<FieldConfig>
{
new FieldConfig("Id", null)
};
var idAndBazId = new List<FieldConfig>
{
new FieldConfig("Id", null),
new FieldConfig("BazId", null)
};
var bazRelationship = new List<ParentConfig>
{
new ParentConfig("Baz", null, null)
};
var idAndBarId = new List<FieldConfig>
{
new FieldConfig("Id", null),
new FieldConfig("BarId", null)
};
var barRelationship = new List<ParentConfig>
{
new ParentConfig("Bar", null, null)
};
var foo = new OracularTable ("Foo", null, barRelationship, idAndBarId);
var tables = new List<OracularTable>
{
foo,
new OracularTable("Bar", null, bazRelationship, idAndBazId),
new OracularTable("Baz", null, null, justAnId)
};
var specs = new List<OracularSpec> ();
var config = new OracularConfig (tables, specs);
var foobarReference = new Reference (new [] { "Foo", "Bar", "Baz" });
var builder = new Sqlizer (foo, config, "Alias");
var sql = foobarReference.Walk (builder);
Assert.AreEqual ("[Alias.Bar.Baz]", sql);
Assert.AreEqual (2, builder.JoinTables.Count ());
}
示例8: ReferenceTypesFromTable
public void ReferenceTypesFromTable(FieldType fieldType, SpecType specType)
{
var fieldConfig = new List<FieldConfig>
{
new FieldConfig("Id", null),
new FieldConfig("Test", fieldType)
};
var tables = new List<OracularTable>
{
new OracularTable ("Foobar", null, null, fieldConfig)
};
var config = new OracularConfig (tables, new List<OracularSpec> ());
var reference = new Reference (new string[]{ "Foobar", "Test" });
var refType = reference.Walk (new TypeChecker (config));
Assert.AreEqual (specType, refType.Type);
}
示例9: ExpectTableToExist
public void ExpectTableToExist()
{
var reference = new Reference (new string[]{ "Foobar", "Test" });
var ex = Assert.Throws<TypeCheckException> (() => reference.Walk (new TypeChecker ()));
Assert.That (ex.Message, Is.StringContaining ("name"));
}
示例10: ExpectParentToExist
public void ExpectParentToExist()
{
var justAnId = new List<FieldConfig>
{
new FieldConfig("Id", null)
};
var tables = new List<OracularTable>
{
new OracularTable("Foobar", null, null, justAnId)
};
var config = new OracularConfig (tables, new List<OracularSpec> ());
var reference = new Reference (new string[]{ "Foobar", "Parent", "Test" });
var ex = Assert.Throws<TypeCheckException> (() => reference.Walk (new TypeChecker (config)));
Assert.That (ex.Message, Is.StringContaining ("parent"));
}