Skip to content

Commit eff0dc9

Browse files
CormacLennonLennonslorello89
authored
fix: Casting to IQueryable no longer drops chunk size (#455)
* fix: Casting to IQueryable no longer drops chunk size * including saveState * adding contributor to readme --------- Co-authored-by: Lennon <[email protected]> Co-authored-by: slorello89 <[email protected]>
1 parent 66c2f0c commit eff0dc9

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ We'd love your contributions! If you want to contribute please read our [Contrib
472472
* [@axnetg](https://github.com/axnetg)
473473
* [@abbottdev](https://github.com/abbottdev)
474474
* [@PrudiusVladislav](https://github.com/PrudiusVladislav)
475+
* [@CormacLennon](https://github.com/CormacLennon)
475476

476477
<!-- Logo -->
477478
[Logo]: images/logo.svg

src/Redis.OM/Searching/RedisQueryProvider.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ public IQueryable CreateQuery(Expression expression)
8484
(IQueryable)Activator.CreateInstance(
8585
typeof(RedisCollection<>).MakeGenericType(elementType),
8686
this,
87-
expression);
87+
expression,
88+
StateManager,
89+
null,
90+
_saveState,
91+
_chunkSize);
8892
}
8993
catch (TargetInvocationException e)
9094
{
@@ -102,7 +106,7 @@ public IQueryable<TElement> CreateQuery<TElement>(Expression expression)
102106
where TElement : notnull
103107
{
104108
var booleanExpression = expression as Expression<Func<TElement, bool>>;
105-
return new RedisCollection<TElement>(this, expression, StateManager, booleanExpression, true);
109+
return new RedisCollection<TElement>(this, expression, StateManager, booleanExpression, _saveState, _chunkSize);
106110
}
107111

108112
/// <inheritdoc/>

test/Redis.OM.Unit.Tests/RediSearchTests/SearchTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3822,5 +3822,22 @@ public async Task EnumerateAllButAllExpired()
38223822

38233823
Assert.Empty(people);
38243824
}
3825+
3826+
[Fact]
3827+
public void TestBasicQueryCastToIQueryable()
3828+
{
3829+
_substitute.ClearSubstitute();
3830+
_substitute.Execute(Arg.Any<string>(), Arg.Any<object[]>()).Returns(_mockReply);
3831+
var y = 33;
3832+
var collection = new RedisCollection<Person>(_substitute, 1234) as IQueryable<Person>;
3833+
_ = collection.Where(x => x.Age < y).ToList();
3834+
_substitute.Received().Execute(
3835+
"FT.SEARCH",
3836+
"person-idx",
3837+
"(@Age:[-inf (33])",
3838+
"LIMIT",
3839+
"0",
3840+
"1234");
3841+
}
38253842
}
38263843
}

0 commit comments

Comments
 (0)