Пример #1
0
        public void InsertFromCTE([IncludeDataSources(TestProvName.AllSQLite)] string context)
        {
            using (var db = GetDataContext(context))
                using (var table = db.CreateLocalTable(InsertTestClass.Seed()))
                    using (var destTable = db.CreateLocalTable <InsertTestClass>("InsertTestClassDest"))
                    {
                        table.AsCte()
                        .Into(destTable)
                        .Insert();

                        var source = table.Single();
                        var result = destTable.Single();

                        Assert.That(source.Value, Is.EqualTo(result.Value));
                        Assert.That(source.OtherValue, Is.EqualTo(result.OtherValue));
                    }
        }
Пример #2
0
        public void InsertFromSql([IncludeDataSources(TestProvName.AllSQLite)] string context)
        {
            using (var db = GetDataContext(context))
                using (var table = db.CreateLocalTable(InsertTestClass.Seed()))
                    using (var destTable = db.CreateLocalTable <InsertTestClass>("InsertTestClassDest"))
                    {
                        db.FromSql <InsertTestClass>("select * from InsertTestClass")
                        .Select(x => new InsertTestClass()
                        {
                            Id = x.Id + 1, Value = x.Value
                        })
                        .Into(destTable)
                        .Insert();

                        var source = table.Single();
                        var result = destTable.Single();

                        Assert.That(source.Value, Is.EqualTo(result.Value));
                        Assert.That(result.OtherValue, Is.Null);
                    }
        }