C# can turn lambdas into expression trees at runtime allowing libraries like EF to transform code like `db.Products.Where(p => p.Price < 100).Select(p => p.Name);` right to SQL by iterating the structure of that code. JavaScript ORMs would be revolutionized if they had this ability.
whstl|9 months ago
In languages that don't have expression inspection capabilities you have to replace the `(p) => p.Price < 100` part with something that is possible for the language to inspect.
Normally it's strings or something using a builder pattern.
For example, in TypeORM:
And in Mongoose: The LINQ-ish version would be: --Similarly, for Ruby on Rails:
Ruby's Sequel overloads operators to have a more natural syntax: But the "lambda" syntax would be:pjmlp|9 months ago
https://github.com/dotnet/csharplang/discussions/158
contextfree|9 months ago
shellac|9 months ago
zigzag312|9 months ago
vosper|9 months ago
Is this possible in JavaScript?
paavohtl|9 months ago
Arnavion|9 months ago