public BaseIntegrationTest(IDatabaseDriver databaseDriver, string connectionString, bool drop) { var mapper = new Mapper(); connection = FolkeConnection.Create(databaseDriver, mapper, connectionString); transaction = connection.BeginTransaction(); connection.CreateTable <TestPoco>(drop: drop); connection.CreateTable <TestManyPoco>(drop: drop); connection.CreateTable <TestCollection>(drop: drop); connection.CreateTable <TestCollectionMember>(drop: drop); connection.CreateTable <TestOtherPoco>(drop: drop); connection.CreateTable <TestMultiPoco>(drop); connection.CreateTable <Playground>(drop); var parentTableWithGuidMapping = mapper.GetTypeMapping <ParentTableWithGuid>(); parentTableWithGuidMapping.Property(x => x.Key).HasColumnName("KeyColumn"); parentTableWithGuidMapping.HasKey(x => x.Key); connection.CreateOrUpdateTable <TableWithGuid>(); connection.CreateOrUpdateTable <ParentTableWithGuid>(); connection.CreateOrUpdateTable <GrandParentWithGuid>(); testValue = new TableWithGuid { Id = Guid.NewGuid(), Text = "Text" }; connection.Save(testValue); }
public BaseIntegrationTestSchemaUpdater(IDatabaseDriver driver, string connectionString, bool drop) { var mapper = new Mapper(); connection = FolkeConnection.Create(driver, mapper, connectionString); transaction = connection.BeginTransaction(); connection.CreateTable <FirstClass>(drop); connection.CreateTable <SecondClass>(drop); }
public TestManyToManyHelpers() { var driver = new MySqlDriver(); var newMapper = new Mapper(); connection = FolkeConnection.Create(driver, newMapper, TestHelpers.ConnectionString); connection.CreateOrUpdateTable <ParentClass>(); connection.CreateOrUpdateTable <ChildClass>(); connection.CreateOrUpdateTable <LinkClass>(); }
public IntegrationTestUserStore() { //var driver = new MicrosoftSqlServerDriver(); var driver = new SqliteDriver(); ElmOptions options = new ElmOptions { ConnectionString = "Data Source=:memory:" //ConnectionString = "Server=SIDOTRON2\\SQLEXPRESS;Database=test;Integrated Security=True" }; this.connection = new FolkeConnection(driver, new Mapper(), new OptionsWrapper <ElmOptions>(options)); }
public TestQueryBuilderExtensions() { var driver = new MySqlDriver(); var mapper = new Mapper(); connection = FolkeConnection.Create(driver, mapper, TestHelpers.ConnectionString); transaction = connection.BeginTransaction(); connection.CreateOrUpdateTable <TestPoco>(); connection.CreateOrUpdateTable <TestManyPoco>(); testPoco = new TestPoco { Name = "FakeName" }; connection.Save(testPoco); }
static void Main(string[] args) { var mapper = new Mapper(); var table = mapper.GetTypeMapping <Table>(); table.ToTable("Blabla"); table.HasKey(x => x.Id); var elmOptions = new ElmOptions { ConnectionString = "Data Source=:memory:" }; var folke = new FolkeConnection(new SqliteDriver(), mapper, new OptionsWrapper <ElmOptions>(elmOptions)); folke.CreateTable <Table>(); folke.Save(new Table()); }
public IList <TableDefinition> GetTableDefinitions(FolkeConnection connection) { var list = new List <TableDefinition>(); using (var command = connection.CreateCommand()) { command.CommandText = $"SELECT name FROM {connection.Database}.sqlite_master WHERE TYPE='table'"; using (var reader = command.ExecuteReader()) { while (reader.Read()) { list.Add(new TableDefinition { Name = reader.GetString(0) }); } } } return(list); }
public IList <IColumnDefinition> GetColumnDefinitions(FolkeConnection connection, TypeMapping typeMap) { var list = new List <IColumnDefinition>(); using (var command = connection.CreateCommand()) { command.CommandText = $"PRAGMA table_info({typeMap.TableName})"; using (var reader = command.ExecuteReader()) { while (reader.Read()) { list.Add(new SqliteColumnDefinition { ColumnName = reader.GetString(1), ColumnType = reader.GetString(2) }); } } } return(list); }
public IntegrationTestFluent() { var driver = new MySqlDriver(); var mapper = new Mapper(); connection = FolkeConnection.Create(driver, mapper, TestHelpers.ConnectionString); connection.CreateTable <TestPoco>(drop: true); connection.CreateTable <TestManyPoco>(drop: true); connection.CreateTable <TestMultiPoco>(drop: true); connection.CreateTable <TestCollection>(drop: true); connection.CreateTable <TestCollectionMember>(drop: true); var poco = new TestPoco { Boolean = true, Name = "FakePoco" }; connection.Save(poco); var many = new TestManyPoco { Poco = poco, Toto = "FakeMany" }; connection.Save(many); }
public IntegrationTestMicrosoftSqlServerDriver() { driver = new MicrosoftSqlServerDriver(); connection = FolkeConnection.Create(driver, new Mapper(), TestHelpers.ConnectionString); transaction = connection.BeginTransaction(); }
public IList <TableDefinition> GetTableDefinitions(FolkeConnection connection) { return(connection.Select <Tables>().All().From().ToList().Select(x => new TableDefinition { Name = x.Name, Schema = x.Schema }).ToList()); }
public IList <IColumnDefinition> GetColumnDefinitions(FolkeConnection connection, TypeMapping typeMap) { var tableSchema = typeMap.TableSchema ?? "dbo"; return(connection.Select <ColumnDefinition>().All().From().Where(x => x.TABLE_NAME == typeMap.TableName && x.TABLE_SCHEMA == tableSchema).ToList().Cast <IColumnDefinition>().ToList()); }
public IList <IColumnDefinition> GetColumnDefinitions(FolkeConnection connection, TypeMapping typeMap) { var tableSchema = typeMap.TableSchema ?? "public"; return(connection.Select <PostgreSqlColumnDefinition>().All().From().Where(x => x.TableName == typeMap.TableName && x.TableSchema == tableSchema).ToList().Cast <IColumnDefinition>().ToList()); }
public IList <IColumnDefinition> GetColumnDefinitions(FolkeConnection connection, TypeMapping typeMap) { return(connection.Select <MySqlColumnDefinition>().All().From().Where(x => x.TABLE_NAME == typeMap.TableName && x.TABLE_SCHEMA == connection.Database).ToList().Cast <IColumnDefinition>().ToList()); }