Skip to content

MRE.ToExpression throws exception #23

Description

@Vrungar

I am trying to get the following to work:

var rule = Rule.Create("Description", "Contains", "Do");
var expression = MRE.ToExpression<T>(rule);
var retVal = records.AsQueryable()
                    .Where(expression)
                    .ToList();

where records is a collection of T having a property named Description.
When I run the above code MRE.ToExpression<T>(rule) throws an InvalidOperationException with the message: No method 'Contains' on type 'System.String' is compatible with the supplied arguments.' exception.

Also found out that the following will throw the same exception when trying to compile the rule:

var rule = Rule.Create("Description", "Contains", "Do");
var compiledRule = new MRE().CompileRule<T>(rule);
var retVal = records.AsQueryable()
                    .Where(r => compiledRule(r))
                    .ToList();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions