Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PredicateBuilder.New<T>(IEnumerable<T>) #138

Merged
merged 2 commits into from
Mar 16, 2021
Merged

PredicateBuilder.New<T>(IEnumerable<T>) #138

merged 2 commits into from
Mar 16, 2021

Conversation

LucasDiogoDeon
Copy link
Contributor

Possibility to create ExpressionStarter instances with Anonymous Types.

Usage:

var ienumerable = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, }
    .Select(x => new
    {
        number = x,
        squared = x * x,
    });
var predicate = PredicateBuilder.Create(ienumerable);
predicate = predicate.Or(x => x.number <= 2);
predicate = predicate.Or(x => x.squared >= 64);

…ressionStarter<T> instances with Anonymous Types.

Usage:
```csharp
var ienumerable = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, }
    .Select(x => new
    {
        number = x,
        squared = x * x,
    });
var predicate = PredicateBuilder.Create(ienumerable);
predicate = predicate.Or(x => x.number <= 2);
predicate = predicate.Or(x => x.squared >= 64);
```
Copy link
Contributor

@sdanyliv sdanyliv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Copy link
Collaborator

@StefH StefH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look at my comments....

/// </summary>
/// <typeparam name="T">The type</typeparam>
/// <param name="ienumerable">The value is NOT used. Only serves as a way to provide the generic type.</param>
public static ExpressionStarter<T> Create<T>(IEnumerable<T> ienumerable, Expression<Func<T, bool>> expr = null)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a better name be New, just like before?

/// </summary>
/// <typeparam name="T">The type</typeparam>
/// <param name="ienumerable">The value is NOT used. Only serves as a way to provide the generic type.</param>
public static ExpressionStarter<T> Create<T>(IEnumerable<T> ienumerable, bool defaultExpression)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a better name be New, just like before?

[Fact]
public void PredicateBuilder_Create()
{
var ienumerable = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LucasDiogoDeon
Copy link
Contributor Author

Changed from Create to New.

@StefH StefH changed the title PredicateBuilder.Create<T>(IEnumerable<T>) PredicateBuilder.New<T>(IEnumerable<T>) Mar 16, 2021
@StefH StefH merged commit 265e8d1 into scottksmith95:master Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants