Ejemplo n.º 1
0
        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}");
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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);
        }