public void Test2() { var tbd = TableDefinition.FromType <TypeTestModel>(); var table = GetSchema().CreateTable("Test1", tbd); var model = new TypeTestModel(); model.String = "Testing..."; var statement = doob.PgSql.Statements.Insert.Into("TestTable") .AddColumnsFromTableDefinition(tbd) .AddValuesFromObject(model) .AddClause(Returning.Columns(tbd.PrimaryKeys().Select(p => p.GetNameForDb()).ToArray())); var sql = statement.GetSqlCommand(tbd); table.Insert(model); var executor = new DbExecuter(table.GetConnectionString()); var resp = executor.ExecuteReader <TypeTestModel>($"SELECT * FROM {table}"); }
public void Simple1() { //GetSchema().TableDrop("Simple1"); var tbl = GetSchema().CreateIfNotExists().CreateTable <TypeTestModel>("Simple1"); var address = new Address("1030", "Vienna"); address.Position = 27; var tm = new TypeTestModel(); tm.String = "TestString"; tm.Address = address; tm.Strings.Add("s1"); tm.Strings.Add("S2"); tbl.Insert(tm); //var query = tbl.Where.Eq(t => t.Address.Zip, "123"); //var comm = query.GetSqlCommand(tbl.TableDefinition).CommandAsPlainText(); //var q = (IQueryable<TypeTestModel>)PgSqlQueryFactory.Queryable<TypeTestModel>(tbl); var lq = tbl.Queryable().Where(t => t.Address == address).ToList(); //var lq1 = tbl.Queryable().Where(t => t.Address.Zip == "123" && t.String == "TestString").Where(t2 => t2.Address.Position == 99).ToList(); }
public void Test1() { var tbd = TableDefinition.FromType <TypeTestModel>(); var table = GetSchema().CreateTable("Test1", tbd); var model = new TypeTestModel(); model.String = "Testing..."; var statement = doob.PgSql.Statements.Insert.Into("TestTable") .AddColumnsFromTableDefinition(tbd) .AddValuesFromObject(model) .AddClause(Returning.Columns(tbd.PrimaryKeys().Select(p => p.GetNameForDb()).ToArray())); var sql = statement.GetSqlCommand(tbd); table.Insert(model); }