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

System.NotSupportedException: 'The binary operator 'Or' is not supported' #62

Closed
felipesotero opened this issue Mar 11, 2020 · 1 comment

Comments

@felipesotero
Copy link

Hello all. I'm trying to do a simple query using my test table in DynamoDB. But for any OR query I'm getting the System.NotSupportedException: 'The binary operator 'Or' is not supported'. The same applies to OrElse.

Maybe I'm missing some premise in dealing with constraints in DynamoDB or even Linq in C#.

Here's the code:

// The Entity
    [DynamoDBTable("TbRelacionamento")]
    public class TbRelacionamento
    {
        [DynamoDBHashKey]
        public string ID { get; set; }
        // Some other unimportant attributes in between

        // In between the attributes we have Enums 
        public RelacionamentoFgStatusEnum FgStatus { get; set; }

        public bool? Reservado { get; set; } // This is the attribute to be queried for

        // In between the attributes we have DateTimes 
        public DateTime DataEnvioAgendamento { get; set; }

        // And also simple objects
        public List<ProdutoCarrinho> Produtos { get; set; }
    }

Here are the test that breaks with the given exception above

var test2 = context.TbRelacionamentos.Where(x => x.Reservado == false | x.Reservado == null);
var test3 = test2.Take(Limit).ToList();
var test = (from relationship in context.GetTable<TbRelacionamento>()
            where relationship.Reservado == false || relationship.Reservado == null
            select relationship).Take(Limit).ToList();

Is there anything I'm missing?

@scale-tone
Copy link
Owner

@felipesotero , the binary operator 'Or' is not supported, because it is not supported by DynamoDB.

Generally, what I could recommend in such cases is to make two separate queries and then .Union() them.
But in your case it should be way much simpler: you just do .Where(x => x.Reservado != true) instead.

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

2 participants