Skip to content

Commit bd1692d

Browse files
committed
#117: Added support for string.Contains and .EndsWith
1 parent 0031390 commit bd1692d

File tree

7 files changed

+316
-140
lines changed

7 files changed

+316
-140
lines changed

src/CHANGELOG.TXT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@
4646
2.8.1: Fixed case problem when checking for Devart Oracle provider
4747
2.9: Added filter options to turn off applying filters to child properties or to prevent them from being applied recursively
4848
2.9.1: Changed Oracle version check to use 'product_component_version' instead of 'v$instance' which is restricted to admins
49+
2.10: Added support for string.Contains and .EndsWith

src/DynamicFiltersTests/ChildCollectionFiltersTests.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/DynamicFiltersTests/DynamicFiltersTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
<Compile Include="EffortTests.cs" />
111111
<Compile Include="BitwiseOperatorTests.cs" />
112112
<Compile Include="ChildPropertyFiltersTests.cs" />
113-
<Compile Include="StartsWithTests.cs" />
113+
<Compile Include="StringFunctionsTests.cs" />
114114
<Compile Include="ContainsTests.cs" />
115115
<Compile Include="DataTypeTests.cs" />
116116
<Compile Include="DisableFilterTests.cs" />

src/DynamicFiltersTests/StartsWithTests.cs

Lines changed: 0 additions & 130 deletions
This file was deleted.

0 commit comments

Comments
 (0)