public void RecursiveTest([CteContextSource(true, ProviderName.DB2)] string context) { using (var db = GetDataContext(context)) { var cteRecursive = db.GetCte<RecursiveCTE>(cte => ( from gc1 in db.GrandChild select new RecursiveCTE { ChildID = gc1.ChildID, ParentID = gc1.GrandChildID, GrandChildID = gc1.GrandChildID, } ) .Concat ( from gc in db.GrandChild from p in db.Parent.InnerJoin(p => p.ParentID == gc.ParentID) from ct in cte.InnerJoin(ct => Sql.AsNotNull(ct.ChildID) == gc.ChildID) where ct.GrandChildID <= 10 select new RecursiveCTE { ChildID = ct.ChildID, ParentID = ct.ParentID, GrandChildID = ct.ChildID + 1 } ) , "MY_CTE"); var str = cteRecursive.ToString(); var result = cteRecursive.ToArray(); } }
public void ExpressionMethodOnProperty([DataSources] string context) { using (var db = GetDataContext(context, CreateMappingSchema())) { var testData = GenerateData(); using (var table = db.CreateLocalTable(testData)) { Assert.AreEqual(testData.Length, table.Where(t => Sql.AsNotNull(t.EntityValue) == t.Id.ToString() + t.Value).Count()); } } }
public void AsNotNullTest([DataSources] string context) { using (var db = GetDataContext(context)) AreEqual( from p1 in Parent from p2 in Parent where p1.Value1 != null && p1.Value1 == p2.Value1 select p1, from p1 in db.Parent from p2 in db.Parent where Sql.AsNotNull(p1.Value1) == Sql.AsNotNull(p2.Value1) select p1); }