Skip to content

Commit

Permalink
#117: Added support for string.Contains and .EndsWith
Browse files Browse the repository at this point in the history
  • Loading branch information
jcachat committed Jul 25, 2017
1 parent 0031390 commit bd1692d
Show file tree
Hide file tree
Showing 7 changed files with 316 additions and 140 deletions.
1 change: 1 addition & 0 deletions src/CHANGELOG.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@
2.8.1: Fixed case problem when checking for Devart Oracle provider
2.9: Added filter options to turn off applying filters to child properties or to prevent them from being applied recursively
2.9.1: Changed Oracle version check to use 'product_component_version' instead of 'v$instance' which is restricted to admins
2.10: Added support for string.Contains and .EndsWith
47 changes: 47 additions & 0 deletions src/DynamicFiltersTests/ChildCollectionFiltersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ public void ChildCollection_ManyToManyLoadGeneratedTable()
}
}

// Tests issue #117
[TestMethod]
public void ChildCollection_AnyContains()
{
using (var context = new TestContext())
{
var list = context.EntityISet.ToList();
Assert.IsTrue((list.Count == 1) && list.All(a => (a.ID == 1)));
}
}

#region Models

public class EntityBase
Expand Down Expand Up @@ -211,6 +222,19 @@ public EntityH()
public bool IsDeleted { get; set; }
}

public class EntityI : EntityBase
{
public ICollection<EntityIChild> Children { get; set; }
}

public class EntityIChild : EntityBase
{
public int ParentID { get; set; }
public EntityI Parent { get; set; }

public string ChildValue { get; set; }
}

#endregion

#region TestContext
Expand All @@ -231,6 +255,8 @@ public class TestContext : TestContextBase<TestContext>, ITestContext
public DbSet<EntityFChild> EntityFChildSet { get; set; }
public DbSet<EntityG> EntityGSet { get; set; }
public DbSet<EntityH> EntityHSet { get; set; }
public DbSet<EntityI> EntityISet { get; set; }
public DbSet<EntityIChild> EntityIChildSet { get; set; }

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
Expand Down Expand Up @@ -266,6 +292,8 @@ protected override void OnModelCreating(DbModelBuilder modelBuilder)

modelBuilder.Filter("ISoftDeleteFilter", (ISoftDelete d) => d.IsDeleted, false);

modelBuilder.Filter("EntityIFilter", (EntityI i, string val) => i.Children.Any(c => c.ChildValue.Contains(val)), () => "23");

// TODO: Count()
// TODO: Count([predicate])
// TODO: Where([predicate])
Expand Down Expand Up @@ -362,6 +390,25 @@ public override void Seed()
}
});

EntityISet.Add(new EntityI
{
ID = 1,
Children = new List<EntityIChild>
{
new EntityIChild { ID = 1, ChildValue = "1234" },
new EntityIChild { ID = 2, ChildValue = "5678" },
}
});
EntityISet.Add(new EntityI
{
ID = 2,
Children = new List<EntityIChild>
{
new EntityIChild { ID = 3, ChildValue = "abcd" },
new EntityIChild { ID = 4, ChildValue = "edfg" },
}
});

SaveChanges();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/DynamicFiltersTests/DynamicFiltersTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
<Compile Include="EffortTests.cs" />
<Compile Include="BitwiseOperatorTests.cs" />
<Compile Include="ChildPropertyFiltersTests.cs" />
<Compile Include="StartsWithTests.cs" />
<Compile Include="StringFunctionsTests.cs" />
<Compile Include="ContainsTests.cs" />
<Compile Include="DataTypeTests.cs" />
<Compile Include="DisableFilterTests.cs" />
Expand Down
130 changes: 0 additions & 130 deletions src/DynamicFiltersTests/StartsWithTests.cs

This file was deleted.

Loading

0 comments on commit bd1692d

Please sign in to comment.