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


C# IDbConnection.SingleById方法代码示例

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


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

示例1: CreateAndInitialize

        private DefaultValues CreateAndInitialize(IDbConnection db, int count = 1)
        {
            db.DropAndCreateTable<DefaultValues>();
            db.GetLastSql().Print();

            DefaultValues firstRow = null;
            for (var i = 1; i <= count; i++)
            {
                var defaultValues = new DefaultValues { Id = i };
                db.Insert(defaultValues);

                var row = db.SingleById<DefaultValues>(1);
                row.PrintDump();
                Assert.That(row.DefaultInt, Is.EqualTo(1));
                Assert.That(row.DefaultIntNoDefault, Is.EqualTo(0));
                Assert.That(row.NDefaultInt, Is.EqualTo(1));
                Assert.That(row.DefaultDouble, Is.EqualTo(1.1).Within(.1d));
                Assert.That(row.NDefaultDouble, Is.EqualTo(1.1).Within(.1d));
                Assert.That(row.DefaultString, Is.EqualTo("String"));

                if (firstRow == null)
                    firstRow = row;
            }

            return firstRow;
        }
开发者ID:BruceCowan-AI,项目名称:ServiceStack.OrmLite,代码行数:26,代码来源:DefaultValueTests.cs

示例2: Run

        protected override void Run(IDbConnection db)
		{
			if (this.IsFirstRun)
			{
				db.CreateTable<Supplier>(true);

				db.Insert(NorthwindFactory.Supplier(SupplierId, "Exotic Liquids", "Charlotte Cooper", "Purchasing Manager", "49 Gilbert St.", "London", null, "EC1 4SD", "UK", "(171) 555-2222", null, null));
			}

            db.SingleById<Supplier>(SupplierId);
		}
开发者ID:CormacBrennan-AI,项目名称:ServiceStack.OrmLite,代码行数:11,代码来源:SelectNorthwindSupplierScenario.cs

示例3: RunMigrations

        internal static void RunMigrations(IDbConnection p_Connection, String p_DatabaseVersion)
        {
            switch (p_DatabaseVersion)
            {
                case "1.2.0.0":
                    RunMigrations1300(p_Connection);
                    break;

                case "1.1.2.1":
                    RunMigrations1200(p_Connection);
                    RunMigrations1300(p_Connection);
                    break;

                case "1.1.2.0":
                    RunMigrations1121(p_Connection);
                    RunMigrations1200(p_Connection);
                    RunMigrations1300(p_Connection);
                    break;

                case "1.1.0.0":
                    RunMigrations1120(p_Connection);
                    RunMigrations1121(p_Connection);
                    RunMigrations1200(p_Connection);
                    RunMigrations1300(p_Connection);
                    break;

                case "1.0.1.0":
                    RunMigrations1100(p_Connection);
                    RunMigrations1120(p_Connection);
                    RunMigrations1121(p_Connection);
                    RunMigrations1200(p_Connection);
                    RunMigrations1300(p_Connection);
                    break;

                case "1.0.0.0":
                    RunMigrations1010(p_Connection);
                    RunMigrations1100(p_Connection);
                    RunMigrations1120(p_Connection);
                    RunMigrations1121(p_Connection);
                    RunMigrations1200(p_Connection);
                    RunMigrations1300(p_Connection);
                    break;
            }

            var s_Version = p_Connection.SingleById<CoreSetting>("gcver");
            s_Version.Value = Application.GetVersion();

            p_Connection.Update(s_Version);
        }
开发者ID:WildGenie,项目名称:GrooveCaster,代码行数:49,代码来源:Migrations.cs

示例4: CreateAndInitialize

        private DefaultValues CreateAndInitialize(IDbConnection db)
        {
            db.DropAndCreateTable<DefaultValues>();

            db.GetLastSql().Print();

            db.Insert(new DefaultValues { Id = 1 });


            var row = db.SingleById<DefaultValues>(1);

            row.PrintDump();
            Assert.That(row.DefaultInt, Is.EqualTo(1));
            Assert.That(row.DefaultIntNoDefault, Is.EqualTo(0));
            Assert.That(row.NDefaultInt, Is.EqualTo(1));
            Assert.That(row.DefaultDouble, Is.EqualTo(1.1).Within(.1d));
            Assert.That(row.NDefaultDouble, Is.EqualTo(1.1).Within(.1d));
            Assert.That(row.DefaultString, Is.EqualTo("String"));

            return row;
        }
开发者ID:ServiceStack,项目名称:ServiceStack.OrmLite,代码行数:21,代码来源:DefaultValueTests.cs

示例5: VerifyUpdateDate

 private static void VerifyUpdateDate(IDbConnection db, int id = 1)
 {
     var row = db.SingleById<DefaultValues>(id);
     row.PrintDump();
     Assert.That(row.UpdatedDateUtc, Is.GreaterThan(DateTime.UtcNow - TimeSpan.FromMinutes(5)));
 }
开发者ID:BruceCowan-AI,项目名称:ServiceStack.OrmLite,代码行数:6,代码来源:DefaultValueTests.cs


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