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


C# DataConnection.GetTable方法代码示例

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


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

示例1: Main

		static void Main(string[] args)
		{
			SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);

			using (var db = new DataConnection())
			{
				var list = db.GetTable<AllTypes2>().ToList();
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:9,代码来源:Program.cs

示例2: Test

 //        [Fact]
 public void Test()
 {
     if (TestBase.UserProviders.ContainsKey("SqlServer.2012"))
     {
         using (var db = new DataConnection("SqlServer.2012"))
         {
             var count = db.GetTable<Parent>().Count();
         }
     }
 }
开发者ID:Convey-Compliance,项目名称:linq2db,代码行数:11,代码来源:PartialTrustTests.cs

示例3: Test

		public void Test()
		{
			//var conn = new System.Data.SQLite.SQLiteConnection();
			//var conn = new IBM.Data.Informix.IfxConnection();

			using (var db = new DataConnection("SqlServer.2012"))
			{
				var count = db.GetTable<Parent>().Count();
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:10,代码来源:PartialTrustTests.cs

示例4: BulkCopyLinqTypes

        public void BulkCopyLinqTypes(string context)
        {
            foreach (var bulkCopyType in new[] { BulkCopyType.MultipleRows, BulkCopyType.ProviderSpecific })
            {
                using (var db = new DataConnection(context))
                {
                    db.BulkCopy(
                        new BulkCopyOptions { BulkCopyType = bulkCopyType },
                        Enumerable.Range(0, 10).Select(n =>
                            new LinqDataTypes
                            {
                                ID            = 4000 + n,
                                MoneyValue    = 1000m + n,
                                DateTimeValue = new DateTime(2001,  1,  11,  1, 11, 21, 100),
                                BoolValue     = true,
                                GuidValue     = Guid.NewGuid(),
                                SmallIntValue = (short)n
                            }
                        ));

                    db.GetTable<LinqDataTypes>().Delete(p => p.ID >= 4000);
                }
            }
        }
开发者ID:jack128,项目名称:linq2db,代码行数:24,代码来源:MySqlTest.cs

示例5: DeleteBigTableTest

		public void DeleteBigTableTest([Values(
			ProviderName.SqlServer,  
			ProviderName.Oracle,
			ProviderName.Sybase)] string configString)
		{
			using (var db = new DataConnection(configString))
			{
				while (db.GetTable<TestTable>().Take(10000).Delete() > 0);
			}
		}
开发者ID:donners77,项目名称:examples,代码行数:10,代码来源:Tests.cs

示例6: InsertTest2

		public void InsertTest2([Values(
			ProviderName.SqlServer, ProviderName.Access, ProviderName.DB2, ProviderName.Firebird, 
			ProviderName.Informix, ProviderName.MySql, ProviderName.Oracle, ProviderName.PostgreSQL,
			ProviderName.SqlCe, ProviderName.SQLite, ProviderName.Sybase)] string configString)
		{
			using (var db = new DataConnection(configString))
			{
				db.GetTable<TestTable>()
					.Insert(() => new TestTable
					{
						Name      = "Crazy Frog",
						CreatedOn = Sql.CurrentTimestamp
					});
			}
		}
开发者ID:donners77,项目名称:examples,代码行数:15,代码来源:Tests.cs

示例7: UpdateTest4

		public void UpdateTest4([Values(
			ProviderName.SqlServer, ProviderName.Access, ProviderName.DB2, ProviderName.Firebird, 
			ProviderName.Informix, ProviderName.MySql, ProviderName.Oracle, ProviderName.PostgreSQL,
			ProviderName.SqlCe, ProviderName.SQLite, ProviderName.Sybase)] string configString)
		{
			using (var db = new DataConnection(configString))
			{
				db
					.GetTable<TestTable>()
					.Where(t => t.ID == 1)
					.Set(t => t.Name,      t => "Crazy Frog IV")
					.Set(t => t.CreatedOn, t => t.CreatedOn.Value.AddHours(1))
					.Update();
			}
		}
开发者ID:donners77,项目名称:examples,代码行数:15,代码来源:Tests.cs

示例8: DeleteTest

		public void DeleteTest([Values(
			ProviderName.SqlServer, ProviderName.Access, ProviderName.DB2, ProviderName.Firebird, 
			ProviderName.Informix, ProviderName.MySql, ProviderName.Oracle, ProviderName.PostgreSQL,
			ProviderName.SqlCe, ProviderName.SQLite, ProviderName.Sybase)] string configString)
		{
			using (var db = new DataConnection(configString))
			{
				db
					.GetTable<TestTable>()
					.Where(t => t.ID == 1)
					.Delete();
			}
		}
开发者ID:donners77,项目名称:examples,代码行数:13,代码来源:Tests.cs

示例9: UpdateAssociation5

        public void UpdateAssociation5(string context)
        {
            using (var db = new DataConnection(context))
            {
                var ids = new[] { 10000, 20000 };

                db.GetTable<Table2>()
                    .Where (x => ids.Contains(x.ParentID))
                    .Select(x => x.Table1)
                    .Distinct()
                    .Set(y => y.BoolValue, y => y.Tables2.All(x => x.Value1))
                    .Update();

                var idx = db.LastQuery.IndexOf("INNER JOIN");

                Assert.That(idx, Is.Not.EqualTo(-1));

                idx = db.LastQuery.IndexOf("INNER JOIN", idx + 1);

                Assert.That(idx, Is.EqualTo(-1));
            }
        }
开发者ID:pebezo,项目名称:linq2db,代码行数:22,代码来源:UpdateTest.cs

示例10: UpdateTest3

		public void UpdateTest3([Values(
			ProviderName.SqlServer, ProviderName.Access, ProviderName.DB2, ProviderName.Firebird, 
			ProviderName.Informix, ProviderName.MySql, ProviderName.Oracle, ProviderName.PostgreSQL,
			ProviderName.SqlCe, ProviderName.SQLite, ProviderName.Sybase)] string configString)
		{
			using (var db = new DataConnection(configString))
			{
				db
					.GetTable<TestTable>()
					.Update(
						t => t.ID == 1,
						t => new TestTable
						{
							Name = "Crazy Frog",
						});
			}
		}
开发者ID:donners77,项目名称:examples,代码行数:17,代码来源:Tests.cs

示例11: Data

            public static IEnumerable<SqlTypes> Data(string context)
            {
                if (_data == null)
                    using (var db = new DataConnection(context.Replace(".LinqService", "")))
                        _data = db.GetTable<SqlTypes>().ToList();

                foreach (var item in _data)
                    yield return item;
            }
开发者ID:Convey-Compliance,项目名称:linq2db,代码行数:9,代码来源:SqlServerTypesTests.cs

示例12: ExposeSqlStringParameter

        public void ExposeSqlStringParameter(string context)
        {
            using (var db = new DataConnection(context))
            {
                var p   = "abc";
                var sql = db.GetTable<Person>().Where(t => t.FirstName == p).ToString();

                Console.WriteLine(sql);

                Assert.That(sql, Contains.Substring("(3)"));
            }
        }
开发者ID:Convey-Compliance,项目名称:linq2db,代码行数:12,代码来源:ParameterTests.cs

示例13: TestTransaction2

        public void TestTransaction2(string context)
        {
            using (var db = new DataConnection(context))
            {
                db.GetTable<Parent>().Update(p => p.ParentID == 1, p => new Parent { Value1 = 1 });

                using (var tran = db.BeginTransaction())
                {
                    db.GetTable<Parent>().Update(p => p.ParentID == 1, p => new Parent { Value1 = null });

                    Assert.IsNull(db.GetTable<Parent>().First(p => p.ParentID == 1).Value1);

                    tran.Rollback();

                    Assert.That(1, Is.EqualTo(db.GetTable<Parent>().First(p => p.ParentID == 1).Value1));
                }
            }
        }
开发者ID:jack128,项目名称:linq2db,代码行数:18,代码来源:MySqlTest.cs

示例14: BulkCopyTest

        void BulkCopyTest(string context, BulkCopyType bulkCopyType)
        {
            using (var conn = new DataConnection(context))
            {
                conn.BeginTransaction();

                conn.BulkCopy(new BulkCopyOptions { MaxBatchSize = 50000, BulkCopyType = bulkCopyType },
                    Enumerable.Range(0, 100000).Select(n =>
                        new AllType
                        {
                            ID                  = 2000 + n,
                            bigintDataType      = 3000 + n,
                            smallintDataType    = (short)(4000 + n),
                            tinyintDataType     = (sbyte)(5000 + n),
                            mediumintDataType   = 6000 + n,
                            intDataType         = 7000 + n,
                            numericDataType     = 8000 + n,
                            decimalDataType     = 9000 + n,
                            doubleDataType      = 8800 + n,
                            floatDataType       = 7700 + n,
                            dateDataType        = DateTime.Now,
                            datetimeDataType    = DateTime.Now,
                            timestampDataType   = null,
                            timeDataType        = null,
                            yearDataType        = (1000 + n) % 100,
                            year2DataType       = (1000 + n) % 100,
                            year4DataType       = null,
                            charDataType        = 'A',
                            varcharDataType     = "",
                            textDataType        = "",
                            binaryDataType      = null,
                            varbinaryDataType   = null,
                            blobDataType        = new byte[] { 1, 2, 3 },
                            bitDataType         = null,
                            enumDataType        = "Green",
                            setDataType         = "one",
                            intUnsignedDataType = (uint)(5000 + n),
                        }));

                //var list = conn.GetTable<ALLTYPE>().ToList();

                conn.GetTable<DB2Test.ALLTYPE>().Delete(p => p.SMALLINTDATATYPE >= 5000);
            }
        }
开发者ID:jack128,项目名称:linq2db,代码行数:44,代码来源:MySqlTest.cs

示例15: BulkCopyProviderSpecificLowerCaseColumns

 public void BulkCopyProviderSpecificLowerCaseColumns(string context)
 {
     using (var db = new DataConnection(context))
     {
         var result = db.BulkCopy(
             new BulkCopyOptions { BulkCopyType = BulkCopyType.ProviderSpecific },
             Enumerable.Range(0, 10).Select(n =>
                 new BulkInsertLowerCaseColumns
                 {
                     ID = 4000 + n,
                     MoneyValue = 1000m + n,
                     DateTimeValue = new DateTime(2001, 1, 11, 1, 11, 21, 100),
                     BoolValue = true,
                     GuidValue = Guid.NewGuid(),
                     SmallIntValue = (short)n
                 }
             ));
         Assert.That(result.RowsCopied, Is.EqualTo(10));
         var count = db.GetTable<BulkInsertLowerCaseColumns>().Delete(p => p.ID >= 4000);
         Assert.That(count, Is.EqualTo(10));
     }
 }
开发者ID:Convey-Compliance,项目名称:linq2db,代码行数:22,代码来源:SapHanaTests.cs


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