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 failing to build correct expression #72

Closed
RehanSaeed opened this issue Jan 12, 2018 · 0 comments
Closed

PredicateBuilder failing to build correct expression #72

RehanSaeed opened this issue Jan 12, 2018 · 0 comments

Comments

@RehanSaeed
Copy link

RehanSaeed commented Jan 12, 2018

I'm trying to use the PredicateBuilder to do an 'Or' in my where clause like so:

var predicate = PredicateBuilder.New<MyItem>();
foreach (var item in items)
{
    predicate = predicate.Or(x => x.Prop1 == item.Prop1 && x.Prop2 == item.Prop2);
}

var result = await this.ApplicationDbContext
    .Items
    .Where(predicate.DefaultExpression)
    .ToListAsync(cancellationToken);

This executes the SQL:

SELECT [f].[Prop1], [f].[Prop2]
FROM [foo].[MyItem] AS [f]
WHERE 0 = 1

Here is what MyItem looks like, it has nullable properties:

public class MyItem
{
    int? Prop1 { get; set; }
    int? Prop2 { get; set; }
}

The expression does not seem to be built properly and no 'Or' clauses get added. Are nullable types supported?

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

No branches or pull requests

1 participant