C #, Linq2SQL: creating expressions

How do you do this?

I am sitting here and trying to make things easier for myself and for others. But I can't seem to decide which way would be the best. The problem is this:

Start by collecting something from the data context, and then start filtering the entire chain of different criteria. If it is, then those or perhaps those, if it is not what it is, but what is between them and above the hill, except if there is nothing but back, up and on.

Well, maybe it’s not so difficult ... but I basically need to create these trees:

        start
          |
          x
          |
          x
         / \
        x   x
        |   |
        x   x
         \ /
          x
         / \
        x   x
        |   |
        x   |
        |   |
        x   x
         \ /
          x
          |
        result

| And, Or. - Or data.Where(...).Where(...).Where(...) . , Union Concat, ( ). , Expression<Func<T, bool>>.

AndAlso OrElse ( Marc. , . And -, Or ... ...: p

, , . , , , , , , . , . , , , , , .

+3
2

Predicate Builder. Expression - , , (, , API Expression). , . EF Expression.Invoke - , , , 4.0 "".

+2

, , , , , ,

string MinOrMaxOption = "min";
int CompareValue = 5;
var Results = from row in MyData
              where (MinOrMaxOption=="min" && row.ValueA > CompareValue)
              || (MinOrMaxOption=="max" && row.ValueA < CompareValue)
              select row;

, , , . , .

+1

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


All Articles