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


C# Database.SqlQuery方法代码示例

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


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

示例1: ThenMatchedResultsAreReturned

        public void ThenMatchedResultsAreReturned()
        {
            // Biuld
            string nameOrConnectionString = "name=DefaultConnection";
            IDatabase db = new Database(nameOrConnectionString, DbContextConnectionFactory.Get());
            var criteria = new { Id = 1 };

            // Operator
            List<Category> categories = db.SqlQuery<Category>("dbo.GetCategory", criteria).ToList();

            // Check
            foreach (Category cat in categories)
            {
                Assert.AreEqual(criteria.Id, cat.Id);
            }
        }
开发者ID:kosalanuwan,项目名称:snikt,代码行数:16,代码来源:WhenPassingEntityDbContext.cs

示例2: With_valid_arguments_dont_throw

            public void With_valid_arguments_dont_throw()
            {
                var database = new Database(new Mock<InternalContextForMock>().Object);

                var query = database.SqlQuery(typeof(Random), "query");

                Assert.NotNull(query);
                Assert.Null(query.InternalQuery.Streaming);
            }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:9,代码来源:DatabaseTests.cs

示例3: With_null_type_throws

            public void With_null_type_throws()
            {
                var database = new Database(new Mock<InternalContextForMock>().Object);

                Assert.Equal(
                    "elementType",
                    Assert.Throws<ArgumentNullException>(() => database.SqlQuery(null, "query")).ParamName);
            }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:8,代码来源:DatabaseTests.cs

示例4: With_null_parameters_throws

            public void With_null_parameters_throws()
            {
                var database = new Database(new Mock<InternalContextForMock>().Object);

                Assert.Equal(
                    "parameters",
                    Assert.Throws<ArgumentNullException>(() => database.SqlQuery(typeof(Random), "query", null)).ParamName);
            }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:8,代码来源:DatabaseTests.cs

示例5: With_whitespace_SQL_throws

            public void With_whitespace_SQL_throws()
            {
                var database = new Database(new Mock<InternalContextForMock>().Object);

                Assert.Equal(
                    Strings.ArgumentIsNullOrWhitespace("sql"),
                    Assert.Throws<ArgumentException>(() => database.SqlQuery(typeof(Random), " ")).Message);
            }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:8,代码来源:DatabaseTests.cs

示例6: Passing_empty_SQL_string_to_non_generic_database_query_method_throws

        public void Passing_empty_SQL_string_to_non_generic_database_query_method_throws()
        {
            var database = new Database(new Mock<InternalContextForMock>().Object);

            Assert.Equal(Strings.ArgumentIsNullOrWhitespace("sql"), Assert.Throws<ArgumentException>(() => database.SqlQuery(typeof(Random), "")).Message);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:6,代码来源:DbSqlQueryTests.cs

示例7: Passing_null_parameters_to_generic_database_query_method_throws

        public void Passing_null_parameters_to_generic_database_query_method_throws()
        {
            var database = new Database(new Mock<InternalContextForMock>().Object);

            Assert.Equal("parameters", Assert.Throws<ArgumentNullException>(() => database.SqlQuery<Random>("query", null)).ParamName);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:6,代码来源:DbSqlQueryTests.cs

示例8: With_valid_arguments_dont_throw

            public void With_valid_arguments_dont_throw()
            {
                var database = new Database(new Mock<InternalContextForMock>().Object);

                Assert.NotNull(database.SqlQuery<Random>("query"));
            }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:6,代码来源:DatabaseTests.cs


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