Questions tagged [expression-trees]
Expression Trees are an abstract representation of code in a tree structure where each node of the tree represents a programming construct (conditional, assignment, method call, etc.)
41 questions
4
votes
2
answers
352
views
Designing a basic Binary Expression Tree structure
Preface
I need to generate some algebraic expressions for math testing in elementary school. The test should generate a list of expressions compiled according to certain rules and check the ...
0
votes
1
answer
82
views
Deleter for Simple Expression Tree in C++
I have created a simple abstract class called expr_node which will serve as a base class for any expression-related nodes.
My goal is to create a simple deleter ...
4
votes
1
answer
7k
views
A simple method to execute Entity Framework Core queries in parallel
As you might know, EF Core does not support executing multiple queries in parallel on the same context using something like Task.WhenAll.
So you have to write this ...
8
votes
2
answers
389
views
Immutable builder and updater
There aren't enough questions about creating immutable objects... so why not try it again with another approach. This time, it's a builder that maps properties to constructor parameters. Properties ...
3
votes
1
answer
529
views
Evaluate an expression binary tree - Daily Coding Challenge
Here is my solution for the Daily Coding Challenge 50
Given an arithmetic expression in the form of a binary tree, write a function to evaluate it
Example
...
6
votes
3
answers
498
views
Simple object validator with a new API
Quite some time ago I have created the Simple object validator (see also self-answer). The more I used it the more I thougt its API could be better so I have heavily refactored it and would like to ...
2
votes
1
answer
122
views
Populating dropdown lists, using SQL vs. using expression trees and reflection
I'm working with a large enterprise SQL Server database with dozens of tables that are used mainly as lookups to populate dropdown lists, etc. These tables all follow the convention of having (table)...
3
votes
0
answers
60
views
Configure multiple application features by common criteria
My FeatureSerivce provides only basic APIs, so it is good in dealing with single features. Like I can configure only one feauture at a time:
...
2
votes
2
answers
153
views
Creating keys/names from interfaces to avoid strings
There are many APIs that require some kind of a string key/name. I usually try to avoid using raw strings and prefer to use ...
7
votes
2
answers
499
views
Quiz for random boolean expressions
Inspired by the various quiz programs on this site, as well as Simon Tatham's puzzle collection, I thought I'd write a quiz that constructs its questions automatically and randomly. A typical session ...
5
votes
1
answer
2k
views
Adjusting business logic conveniently through JSON and expression trees
I need to evaluate some data. The rules how it should be done are changing frequently (it's an evolving model) so I don't want to rewrite my application each time such a change comes. I'd rather do it ...
4
votes
1
answer
365
views
Dynamic setting names based on properties
In one of my frameworks that I use with many tools I have an ExpressionVisitor whose job is to resolve the exact property, it's declaring type and instance. I ...
1
vote
1
answer
490
views
Expression tree in Haskell with support for differentiation
A simple binary expression tree in Haskell without operator precedence and without parentheses.
Any comments would be much appreciated.
...
14
votes
3
answers
549
views
Building unusual IComparer<T> from expressions
I've needed a couple of very special comparers recenty and didn't want to implement each one of them every time so I created a builder and a couple of supporting classes that do that for me.
Example
...
8
votes
4
answers
1k
views
Selective updates to immutable types
There is a way in Scala to selectively change a field while making a copy of the immutable object:
...
6
votes
1
answer
323
views
Inserting into a binary expression tree with GOTO
I'm working on a binary space partition tree.
For the time being, the nodes are only inserted into the right. A node that has children will have 0 as data. Here are the insertion rules.
If the ...
13
votes
3
answers
1k
views
Building DebuggerDisplay strings
The DebuggerDisplayAttribute is a very helpful feature. But creating those strings is an extremely tedious task. I wanted to make it a no-brainer so that I can ...
2
votes
0
answers
145
views
Implementing the IQueryable counterpart method of the IEnumerable method?
I have created this method to simulate SQL's IN operator:
...
14
votes
6
answers
12k
views
Calculate fingerprint for an object
I need to store serialized objects in a database and I want to avoid duplicates. In order to be able to tell wheter an object is already stored, I have to compare them somehow. My idea was to ...
20
votes
6
answers
17k
views
Simple object validator
I wrote a simple validation tool that allows me to quickly define validation rules and check my data objects against them. I know there is this another tool called FluentValidation but... I'm not a ...
6
votes
4
answers
1k
views
Simple generic sequence generators
I've been improving some of my old sequence generators that worked with generics and lambdas in order to support binary operators for the specified T:
...
9
votes
5
answers
736
views
Declarative type comparer
Writing comparers by either implementing the IEqualityComparer<T> or the IEquatable<T> interface is another boring ...
2
votes
1
answer
485
views
Unit-test helper extensions for binary operators
This time I'd like you to review my unit-test helpers for binary operators. I wrote them because I'm often to lazy to test these operators because writing those tests is so boring.
My little helpers ...
8
votes
1
answer
4k
views
GroupBy(params string[] fields)
Linq to Object GroupBy extension method allows grouping by projection:
...
5
votes
1
answer
2k
views
Extensions for setting members via expressions and reflection
I'd like to make the usage of my configuration framework easier so I created a few extensions that after getting a value from a source automatically assign it to a property or field. They should make ...
2
votes
0
answers
98
views
Computer Algebra System that computes symbolic derivatives
I have a system that parses a mathematical expression String, creates a derivative expression tree, and reconstructs the derived expression into a new ...
5
votes
1
answer
4k
views
Generating variable names and getters from member expression
I have a JSON configuration file where the user is allowed to use inside strings certain placeholders {Type.Name} that later will be interpolated with the actual ...
5
votes
1
answer
9k
views
Parsing and evaluating cron expression
I wasn't happy with my last attempt to parse a cron expression so I simplified it and now I use regex instead. I'd like you to take a look at this solution whether I'm doing something terribly wrong.
...
5
votes
1
answer
207
views
Calculating user efficiency on a time period with Linq
I have this expression:
...
4
votes
1
answer
969
views
Specification pattern in EF part 2
This is a follow on to Part 1
In order to use my new Specifications within expression trees so I can use them in projections/navigation collections I had to write ...
9
votes
2
answers
3k
views
Specification pattern in EF part 1
I've been experimenting with different ways of reusing (and naming) the expressions I use in Entity Framework. I've tried static fields with Expressions and ...
7
votes
1
answer
379
views
LINQ Provider: Supporting Projections
Up until recently, my LINQ-to-Sage provider didn't support projections, so the client code had to explicitly "transfer" to LINQ-to-Objects, like this:
...
3
votes
1
answer
331
views
Validation extensions
I've been working on another timesaver because I really really don't like to type all those validation ifs and exceptions over an over again.
What I came up with ...
4
votes
1
answer
381
views
Binary expression tree node with two possible states
I am building out a binary expression tree and shown below is an implementation of the tree's node.
The node can be either a leaf or non-leaf, with leaves having ...
6
votes
1
answer
10k
views
Tracking which entity properties have changed
There are a number of topics pertaining to entity change tracking. All the ones I've seen involve either 1) notifying when a property has changed or 2) merely determining whether or not an entity is ...
2
votes
1
answer
3k
views
Building expression tree with multiple OrElse
I am creating a way for users to filter results based on start and end values. An example of this would be:
...
10
votes
1
answer
298
views
Linq-to-Sage Implementation
Following-up on my last question where I wrapped the Sage API with a familiar IRepository interface, I decided to push the abstraction a step further, and... ...
12
votes
2
answers
357
views
Something like a LINQ provider
Ok, before you ask: yes, I need to do this. Sort of.
I'm wrapping a 3rd-party API for data access, and I can't use an ORM, so I'm implementing this kind of thing:
...
7
votes
1
answer
386
views
NullGuard for throwing more informative exceptions
This small utility class is my solution for a more convenient way for checking against null. I also wanted to have more informative NullReferenceExceptions but I ...
-1
votes
1
answer
568
views
Refactor Linq Expression [closed]
Is there any way I can refactor this expression tree?
...
10
votes
3
answers
26k
views
Generic advanced Delegate.CreateDelegate using expression trees
As far as I know the standard Delegate.CreateDelegate() which allows to create a delegate by using reflection, doesn't allow doing something as follows when the ...