1

I am working with Entity Spaces and need to run following query

select * from MyTable WHERE (Age * 10) IN (50, 60, 70)

ES version is

query.Where((query.Age * 10).In(AgesList));

This generates following invalid query (Age * 10 is missing)

select * from MyTable WHERE IN (50, 60, 70)

Any solution to produce desired query?

bjan
  • 2,000
  • 7
  • 32
  • 64
  • 1
    Why not run `Age in (5, 6, 7)`, which should map more cleanly? also: surely the broken version is actually something more like `query.Where(x => (x.Age * 10).In(AgesList))`? – Marc Gravell Jan 06 '21 at 07:40
  • @MarcGravell original query is not that simple and involves some arithmetics with multiple columns :) – bjan Jan 06 '21 at 07:42
  • 1
    if the `x => (x.Age * 10).In(AgesList)` is producing invalid SQL, then that sounds like a bug in entity-spaces that should be reported to the maintainers; in the interim - does it allow you to issue ad-hoc SQL? Quite honestly, that might be the pragmatic solution here. – Marc Gravell Jan 06 '21 at 07:46
  • ES does allow raw sql but i am avoiding it for obvious reason. – bjan Jan 06 '21 at 07:47
  • 1
    it isn't "obvious" to me... LINQ has advantages *and* disadvantages - but in this case, it isn't *working*, so... – Marc Gravell Jan 06 '21 at 07:49
  • "obvious" = avoid raw sql if there is a solution in linq/ORM tool. – bjan Jan 06 '21 at 07:51

0 Answers0