Exemplo n.º 1
0
		public void CreateTest([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))
			{
				try { db.DropTable<TestTable>();  } catch {}
				try { db.DropTable<TestTable2>(); } catch {}
				try { db.DropTable<TestTable3>(); } catch {}

				db.CreateTable<TestTable>();
				db.CreateTable<TestTable2>();
				db.CreateTable<TestTable3>();
			}
		}
Exemplo n.º 2
0
		public void Test(string context)
		{
			var firebirdQuote = FirebirdSqlBuilder.IdentifierQuoteMode;

			var schema = new MappingSchema();

			schema.SetDataType(typeof(MyInt), DataType.Int32);

			schema.SetConvertExpression<MyInt,   int>          (x => x.Value);
			schema.SetConvertExpression<int,     MyInt>        (x => new MyInt { Value = x });
			schema.SetConvertExpression<Int64,   MyInt>        (x => new MyInt { Value = (int)x }); //SQLite
			schema.SetConvertExpression<decimal, MyInt>        (x => new MyInt { Value = (int)x }); //Oracle
			schema.SetConvertExpression<MyInt,   DataParameter>(x => new DataParameter { DataType = DataType.Int32, Value = x.Value });

			schema.GetFluentMappingBuilder()
				  .Entity<Entity>()
				  .HasTableName("Issue464")
				  .HasColumn(x => x.Id)
				  .HasColumn(x => x.Value);

			using (var db = new  DataConnection(context).AddMappingSchema(schema))
			{
				try
				{
					FirebirdSqlBuilder.IdentifierQuoteMode = FirebirdIdentifierQuoteMode.Auto;

					var temptable = db.CreateTable<Entity>();

					var data = new[]
					{
						new Entity {Id = 1, Value = new MyInt {Value = 1}},
						new Entity {Id = 2, Value = new MyInt {Value = 2}},
						new Entity {Id = 3, Value = new MyInt {Value = 3}}
					};

					temptable.BulkCopy(data);

					AreEqual(data, temptable.ToList());
				}
				finally
				{
					db.DropTable<Entity>();

					FirebirdSqlBuilder.IdentifierQuoteMode = firebirdQuote;
				}

			}
		}
Exemplo n.º 3
0
        public void PostgreSQLTest(string context)
        {
            using (var conn = new DataConnection(context))
            {
                try { conn.DropTable<PKTest>(); } catch {}

                conn.CreateTable<PKTest>();

                var sp       = conn.DataProvider.GetSchemaProvider();
                var dbSchema = sp.GetSchema(conn);
                var table    = dbSchema.Tables.Single(t => t.TableName == "PKTest");

                Assert.That(table.Columns[0].PrimaryKeyOrder, Is.EqualTo(1));
                Assert.That(table.Columns[1].PrimaryKeyOrder, Is.EqualTo(2));

                conn.DropTable<PKTest>();
            }
        }