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


C# SqlDataAccess.Query方法代码示例

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


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

示例1: QueryToIEnumerableTest

        public void QueryToIEnumerableTest()
        {
            SqlDataAccess data = new SqlDataAccess(STR_ConnectionString);

            var swatch = new Stopwatch();
            swatch.Start();

            var enumerable = data.Query<WebLogEntry>("select * from ApplicationLog");

            var recs = new List<WebLogEntry>();
            foreach (var entry in enumerable)
            {
                recs.Add(entry);
            }

            swatch.Stop();

            Assert.IsNotNull(recs, "Null");
            Assert.IsTrue(recs.Count > 0, "Count < 1");
            Assert.IsTrue(recs[0].Entered > DateTime.MinValue);

            Console.WriteLine(swatch.ElapsedMilliseconds);
            Console.WriteLine(recs.Count);
        }
开发者ID:RickStrahl,项目名称:WestwindToolkit,代码行数:24,代码来源:SqlDataAccessTests.cs

示例2: QueryWithNoMatchingDataTest

        public void QueryWithNoMatchingDataTest()
        {
            SqlDataAccess data = new SqlDataAccess(STR_ConnectionString);

            // no records returned from query
            var entries = data.Query<WebLogEntry>("select * from ApplicationLog where 1=2");

            var ent = entries.ToList();
            Console.WriteLine(ent.Count);

            Assert.IsNotNull(entries, "IEnumerable should not be null - only null on failure.");
        }
开发者ID:RickStrahl,项目名称:WestwindToolkit,代码行数:12,代码来源:SqlDataAccessTests.cs

示例3: QueryToCustomer

        public void QueryToCustomer()
        {
            using (var data = new SqlDataAccess(STR_ConnectionString))
            {
                var custList = data.Query<Customer>("select * from customers where LastName like @0", "S%");

                Assert.IsNotNull(custList, data.ErrorMessage);

                foreach (var customer in custList)
                {
                    Console.WriteLine(customer.Company + " " + customer.Entered);
                }
            }
        }
开发者ID:RickStrahl,项目名称:WestwindToolkit,代码行数:14,代码来源:SqlDataAccessTests.cs

示例4: QueryTest

 public void QueryTest()
 {
     using (var data = new SqlDataAccess(STR_ConnectionString))
     {
         var swatch = Stopwatch.StartNew();
         var logEntries =
             data.Query<WebLogEntry>(
                 "select * from ApplicationLog where entered > @0 and entered < @1 order by Entered",
                 DateTime.Now.AddYears(-115), DateTime.Now.AddYears(-1)).ToList();
         Assert.IsNotNull(logEntries, data.ErrorMessage);
         Console.WriteLine(logEntries.Count);
         foreach (var logEntry in logEntries)
         {
             Console.WriteLine(logEntry.Entered);
         }
         swatch.Stop();
         Console.WriteLine(swatch.ElapsedMilliseconds + "ms");
     }
 }
开发者ID:RickStrahl,项目名称:WestwindToolkit,代码行数:19,代码来源:SqlDataAccessTests.cs

示例5: QueryException

 public void QueryException()
 {
     using (var data = new SqlDataAccess(STR_ConnectionString)
     {
         ThrowExceptions = true
     })
     {
         try
         {
             var logEntries = data.Query<WebLogEntry>("select * from ApplicationLogggg");
             Assert.Fail("Invalid Sql Statement should not continue");
         }
         catch (Exception ex)
         {
             Console.WriteLine("Error caught correctly: " + ex.Message);
         }
     }
 }
开发者ID:RickStrahl,项目名称:WestwindToolkit,代码行数:18,代码来源:SqlDataAccessTests.cs

示例6: NewParametersExecuteEntityTest

 public void NewParametersExecuteEntityTest()
 {
     using (var data = new SqlDataAccess(STR_ConnectionString))
     {
         //var cmd = data.CreateCommand("select * from ApplicationLog where entered > @0 and entered > @1",CommandType.Text, DateTime.Now.AddYears(-10), DateTime.Now.AddYears(-));
         //var table = data.ExecuteTable("TLogs", cmd);
         var swatch = Stopwatch.StartNew();
         var entries =
             data.Query<WebLogEntry>(
                 "select * from ApplicationLog where entered > @0 and entered < @1 order by Entered",
                 DateTime.Now.AddYears(-115), DateTime.Now.AddYears(-1));
         var logEntries = entries.ToList();
         Assert.IsNotNull(logEntries, data.ErrorMessage);
         Console.WriteLine(logEntries.Count);
         foreach (var logEntry in logEntries)
         {
             Console.WriteLine(logEntry.Entered);
         }
         swatch.Stop();
         Console.WriteLine(swatch.ElapsedMilliseconds + "ms");
     }
 }
开发者ID:RickStrahl,项目名称:WestwindToolkit,代码行数:22,代码来源:SqlDataAccessTests.cs

示例7: ExecuteDataReaderToListTest

        public void ExecuteDataReaderToListTest()
        {
            SqlDataAccess data = new SqlDataAccess(STR_ConnectionString);

            var swatch = new Stopwatch();
            swatch.Start();

            var recs = data.Query<WebLogEntry>("select * from ApplicationLog").ToList();

            swatch.Stop();

            Assert.IsNotNull(recs, "Null");
            Assert.IsTrue(recs.Count > 0, "Count < 1");
            Assert.IsTrue(recs[0].Entered > DateTime.MinValue);

            Console.WriteLine(swatch.ElapsedMilliseconds);
            Console.WriteLine(recs.Count);
        }
开发者ID:RickStrahl,项目名称:WestwindToolkit,代码行数:18,代码来源:SqlDataAccessTests.cs


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