當前位置: 首頁>>代碼示例>>C#>>正文


C# Reference.Walk方法代碼示例

本文整理匯總了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);
        }
開發者ID:couchand,項目名稱:oracular-dot-net,代碼行數:21,代碼來源:SqlizerTests.cs

示例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));
        }
開發者ID:couchand,項目名稱:oracular-dot-net,代碼行數:22,代碼來源:RefCheckerTests.cs

示例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);
        }
開發者ID:couchand,項目名稱:oracular-dot-net,代碼行數:22,代碼來源:RefCheckerTests.cs

示例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);
        }
開發者ID:couchand,項目名稱:oracular-dot-net,代碼行數:16,代碼來源:SqlizerTests.cs

示例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);
        }
開發者ID:couchand,項目名稱:oracular-dot-net,代碼行數:16,代碼來源:SqlizerTests.cs

示例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);
        }
開發者ID:couchand,項目名稱:oracular-dot-net,代碼行數:36,代碼來源:SqlizerTests.cs

示例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 ());
        }
開發者ID:couchand,項目名稱:oracular-dot-net,代碼行數:43,代碼來源:SqlizerTests.cs

示例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);
        }
開發者ID:couchand,項目名稱:oracular-dot-net,代碼行數:19,代碼來源:TypeCheckerTests.cs

示例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"));
        }
開發者ID:couchand,項目名稱:oracular-dot-net,代碼行數:8,代碼來源:TypeCheckerTests.cs

示例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"));
        }
開發者ID:couchand,項目名稱:oracular-dot-net,代碼行數:17,代碼來源:TypeCheckerTests.cs


注:本文中的System.Reference.Walk方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。