How do predictive parameters work syntactically in C #?

Some relational object mapping (ORM) structures (such as LLBLGen) allow you to specify "predicate" parameters for query methods, such as (simplified bit):

var entities = adapter.FetchEntities(EntityType.Employee,
    EmployeeFields.Salary > 50000);

How does this 2nd parameter syntactically work in C #? This is similar to a lambda expression, but it does not have a parameter part or "=>". What is it? You may need Jon Skeet for this.

+3
source share
2 answers

If you overloaded the operator " >" to return a predicate object to your special type " SuperDatabaseMapField", you could do such things.

, , (, , ).

+6

mquander's. , , , . LLBLGen -, ().

(+, -, ***,/) - , , ( "+" ). , a ( ) + 2.4 (float), , #, (string) (operator_add) (float).

, , , :

FetchEntities(EntityType.Employee, 
    EmployeeFields.Salary > ((EmployeeFields.DateOfBirth - 10) * 1.2) + 1024)

(- *** +), "".

( "()" )

(BinaryComparison)
    LeftSide: (Field_Reference)    --> EmployeeFields.Salary
    RightSide:
        (MathematicOperator)
            LeftSide:
                (MathematicOperator)
                    LeftSide: 
                        (MathematicOperator)
                            LeftSide: (Field_Reference)    --> EmployeeFields.DateOfBirth
                            RightSide: (constant)    --> 10
                            Operator:      --> -
                    RightSide: (constant)    --> 1.2
                    Operator:     --> ***
            RightSide: (constant)    --> 1024
            Operator:     --> +
    Operator:     --> >

, , - . .

- ... , , .

+2

Source: https://habr.com/ru/post/1714811/


All Articles