mikependon / RepoDB

A hybrid ORM library for .NET.
Apache License 2.0
1.68k stars 122 forks source link

Expression is currently not supported. #1136

Closed mxmissile closed 1 year ago

mxmissile commented 1 year ago

I'm currently testing RepoDb to see if its a good fit for my project. However on my first test I am getting a System.NotSupportedException: Expression 'x => x.Vw' is currently not supported.:

model:

    [Table("items")]
    public class Line
    {
        [Column("item_id")]
        [Key]
        [Identity]
        public int Id { get; set; }

        public bool Vw { get; set; }

        [Column("itemnum")]
        public int Number { get; set; }
    }

simple test:

      var items = cn.Query<Line>(x => x.Vw);

      foreach (var item in items)
      {
          Console.WriteLine(item.Id);
      }

I'm probably missing something obvious!?

mikependon commented 1 year ago

For now, it requires the left and right in the expression tree. Below shoud work.

var items = cn.Query<Line>(x => x.Vw == true);
mxmissile commented 1 year ago

I'm confused, doesn't that evaluate the same (to true)?

mikependon commented 1 year ago

It is, but UnaryExpression support of the library is not extensive as EF. There are other things that are not supported as well, like even a simple field comparisson like (e => e.Field1 != e.Field2).

mikependon commented 1 year ago

We also issued some caveats on our Expression Trees documentation.

Therefore, whatever expression tree that is not supported would automatically be defaulted to the exception thrown on this post.

mxmissile commented 1 year ago

I understand, have you considered ReLinq to handle your expressions? https://github.com/re-motion/Relinq