public void From() { var item = new TestLinqToSql { name = Guid.NewGuid().ToString() }; g.sqlite.Insert <TestLinqToSql>().AppendData(item).ExecuteAffrows(); var comment = new TestLinqToSqlComment { TestLinqToSqlId = item.id, text = Guid.NewGuid().ToString() }; g.sqlite.Insert <TestLinqToSqlComment>().AppendData(comment).ExecuteAffrows(); var t1 = (from a in g.sqlite.Select <TestLinqToSql>() from b in g.sqlite.Select <TestLinqToSqlComment>() where a.id == b.TestLinqToSqlId select a).ToList(); Assert.True(t1.Any()); //Assert.Equal(item.id, t1[0].id); var t2 = (from a in g.sqlite.Select <TestLinqToSql>() from b in g.sqlite.Select <TestLinqToSqlComment>() where a.id == b.TestLinqToSqlId select new { a.id, bid = b.id }).ToList(); Assert.True(t2.Any()); //Assert.Equal(item.id, t2[0].id); //Assert.Equal(comment.id, t2[0].bid); var t3 = (from a in g.sqlite.Select <TestLinqToSql>() from b in g.sqlite.Select <TestLinqToSqlComment>() where a.id == b.TestLinqToSqlId where a.id == item.id select new { a.id, bid = b.id }).ToList(); Assert.True(t3.Any()); Assert.Equal(item.id, t3[0].id); Assert.Equal(comment.id, t3[0].bid); }
public void LeftJoin() { var item = new TestLinqToSql { name = Guid.NewGuid().ToString() }; g.sqlite.Insert <TestLinqToSql>().AppendData(item).ExecuteAffrows(); var comment = new TestLinqToSqlComment { TestLinqToSqlId = item.id, text = Guid.NewGuid().ToString() }; g.sqlite.Insert <TestLinqToSqlComment>().AppendData(comment).ExecuteAffrows(); var t1 = (from a in g.sqlite.Select <TestLinqToSql>() join b in g.sqlite.Select <TestLinqToSqlComment>() on a.id equals b.TestLinqToSqlId into temp from tc in temp.DefaultIfEmpty() select a).ToList(); Assert.True(t1.Any()); //Assert.Equal(item.id, t1[0].id); var t2 = (from a in g.sqlite.Select <TestLinqToSql>() join b in g.sqlite.Select <TestLinqToSqlComment>() on a.id equals b.TestLinqToSqlId into temp from tc in temp.DefaultIfEmpty() select new { a.id, bid = tc.id }).ToList(); Assert.True(t2.Any()); //Assert.Equal(item.id, t2[0].id); //Assert.Equal(comment.id, t2[0].bid); var t3 = (from a in g.sqlite.Select <TestLinqToSql>() join b in g.sqlite.Select <TestLinqToSqlComment>() on a.id equals b.TestLinqToSqlId into temp from tc in temp.DefaultIfEmpty() where a.id == item.id select new { a.id, bid = tc.id }).ToList(); Assert.True(t3.Any()); Assert.Equal(item.id, t3[0].id); Assert.Equal(comment.id, t3[0].bid); }