@@ -96,6 +96,17 @@ public void ChildCollection_ManyToManyLoadGeneratedTable()
9696 }
9797 }
9898
99+ // Tests issue #117
100+ [ TestMethod ]
101+ public void ChildCollection_AnyContains ( )
102+ {
103+ using ( var context = new TestContext ( ) )
104+ {
105+ var list = context . EntityISet . ToList ( ) ;
106+ Assert . IsTrue ( ( list . Count == 1 ) && list . All ( a => ( a . ID == 1 ) ) ) ;
107+ }
108+ }
109+
99110 #region Models
100111
101112 public class EntityBase
@@ -211,6 +222,19 @@ public EntityH()
211222 public bool IsDeleted { get ; set ; }
212223 }
213224
225+ public class EntityI : EntityBase
226+ {
227+ public ICollection < EntityIChild > Children { get ; set ; }
228+ }
229+
230+ public class EntityIChild : EntityBase
231+ {
232+ public int ParentID { get ; set ; }
233+ public EntityI Parent { get ; set ; }
234+
235+ public string ChildValue { get ; set ; }
236+ }
237+
214238 #endregion
215239
216240 #region TestContext
@@ -231,6 +255,8 @@ public class TestContext : TestContextBase<TestContext>, ITestContext
231255 public DbSet < EntityFChild > EntityFChildSet { get ; set ; }
232256 public DbSet < EntityG > EntityGSet { get ; set ; }
233257 public DbSet < EntityH > EntityHSet { get ; set ; }
258+ public DbSet < EntityI > EntityISet { get ; set ; }
259+ public DbSet < EntityIChild > EntityIChildSet { get ; set ; }
234260
235261 protected override void OnModelCreating ( DbModelBuilder modelBuilder )
236262 {
@@ -266,6 +292,8 @@ protected override void OnModelCreating(DbModelBuilder modelBuilder)
266292
267293 modelBuilder . Filter ( "ISoftDeleteFilter" , ( ISoftDelete d ) => d . IsDeleted , false ) ;
268294
295+ modelBuilder . Filter ( "EntityIFilter" , ( EntityI i , string val ) => i . Children . Any ( c => c . ChildValue . Contains ( val ) ) , ( ) => "23" ) ;
296+
269297 // TODO: Count()
270298 // TODO: Count([predicate])
271299 // TODO: Where([predicate])
@@ -362,6 +390,25 @@ public override void Seed()
362390 }
363391 } ) ;
364392
393+ EntityISet . Add ( new EntityI
394+ {
395+ ID = 1 ,
396+ Children = new List < EntityIChild >
397+ {
398+ new EntityIChild { ID = 1 , ChildValue = "1234" } ,
399+ new EntityIChild { ID = 2 , ChildValue = "5678" } ,
400+ }
401+ } ) ;
402+ EntityISet . Add ( new EntityI
403+ {
404+ ID = 2 ,
405+ Children = new List < EntityIChild >
406+ {
407+ new EntityIChild { ID = 3 , ChildValue = "abcd" } ,
408+ new EntityIChild { ID = 4 , ChildValue = "edfg" } ,
409+ }
410+ } ) ;
411+
365412 SaveChanges ( ) ;
366413 }
367414 }
0 commit comments