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)); } }
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); } }